diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-26 19:18:11 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-08-26 20:41:42 +0200 |
commit | 43f447b121b38c01a7c5626a51cc571a822250b8 (patch) | |
tree | aba9099f05dad97784ab515e70217676bbc7a689 /src/libsystemd-network | |
parent | 1ac608c9ccb6b69a6bc8a458e10a05e0fc9a8301 (diff) |
dhcp: be more careful when parsing strings from DHCP packets
Let's make sure there's no embedded 0 byte. Also, let's reset the string
if the length is zero.
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index f5b9e22589..57369a353d 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -287,13 +287,17 @@ static int lease_parse_string(const uint8_t *option, size_t len, char **ret) { if (len >= 1) { char *string; + if (memchr(option, 0, len)) + return -EINVAL; + string = strndup((const char *)option, len); if (!string) - return -errno; + return -ENOMEM; free(*ret); *ret = string; - } + } else + *ret = mfree(*ret); return 0; } |