summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-lease.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-08-15 01:04:53 +0200
committerTom Gundersen <teg@jklm.no>2014-08-15 01:04:53 +0200
commit784d9b9c09aa1ecdc688f251ea423fb47892f498 (patch)
treea9b1c2f10655c38a355b09bcfd808710fb42215f /src/libsystemd-network/sd-dhcp-lease.c
parentbda2c408f8a739c19161818bcc842107f60652a2 (diff)
sd-dhcp-lease: verify hostname and domainnames we receive
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-lease.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index bfd1b0cd18..e8cfd72c01 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -513,19 +513,39 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
break;
case DHCP_OPTION_DOMAIN_NAME:
- r = lease_parse_string(option, len, &lease->domainname);
+ {
+ _cleanup_free_ char *domainname = NULL;
+
+ r = lease_parse_string(option, len, &domainname);
if (r < 0)
return r;
- break;
+ if (!hostname_is_valid(domainname) || is_localhost(domainname))
+ break;
+
+ free(lease->domainname);
+ lease->domainname = domainname;
+ domainname = NULL;
+ break;
+ }
case DHCP_OPTION_HOST_NAME:
- r = lease_parse_string(option, len, &lease->hostname);
+ {
+ _cleanup_free_ char *hostname = NULL;
+
+ r = lease_parse_string(option, len, &hostname);
if (r < 0)
return r;
- break;
+ if (!hostname_is_valid(hostname))
+ break;
+
+ free(lease->hostname);
+ lease->hostname = hostname;
+ hostname = NULL;
+ break;
+ }
case DHCP_OPTION_ROOT_PATH:
r = lease_parse_string(option, len, &lease->root_path);
if (r < 0)