summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)