summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-26 19:16:52 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-26 20:41:22 +0200
commit1ac608c9ccb6b69a6bc8a458e10a05e0fc9a8301 (patch)
tree9c36f6ae6f27dcce049f24012583142110506b25 /src/network/networkd-network.c
parent5c904ba5a5f0953b568ae257b9667222d1d21808 (diff)
networkd: don't leak memory of Hostname= is used twice in a .network file
Also, we should only accept trailing dots where we have to, but not everywhere, hence be more strict when validating configured hostnames.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 6587ea994c..8f773e738d 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -816,37 +816,36 @@ int config_parse_ipv6_privacy_extensions(
return 0;
}
-int config_parse_hostname(const char *unit,
- const char *filename,
- unsigned line,
- const char *section,
- unsigned section_line,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
- char **hostname = data;
- char *hn = NULL;
+int config_parse_hostname(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ char **hostname = data, *hn = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- r = config_parse_string(unit, filename, line, section, section_line,
- lvalue, ltype, rvalue, &hn, userdata);
+ r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &hn, userdata);
if (r < 0)
return r;
- if (!hostname_is_valid(hn, true)) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "hostname is not valid, ignoring assignment: %s", rvalue);
-
+ if (!hostname_is_valid(hn, false)) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Hostname is not valid, ignoring assignment: %s", rvalue);
free(hn);
return 0;
}
+ free(*hostname);
*hostname = hostname_cleanup(hn);
-
return 0;
}