diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-30 23:35:18 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-30 23:35:18 +0200 |
commit | e989fd9b67f5e19b115e940d397a83e260668763 (patch) | |
tree | e6d7b22578ec723103c1b19de277898201a9bb95 | |
parent | fe08a30b58bba0e04fb3e43122e0b157af5846a1 (diff) |
dhcp: make sure we can deal with a single trailing NUL byte in the hostname
Fixes #1337
-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 aa07846693..df3d8e6e3c 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -314,10 +314,14 @@ static int lease_parse_string(const uint8_t *option, size_t len, char **ret) { else { char *string; - if (memchr(option, 0, len)) + /* + * One trailing NUL byte is OK, we don't mind. See: + * https://github.com/systemd/systemd/issues/1337 + */ + if (memchr(option, 0, len - 1)) return -EINVAL; - string = strndup((const char *)option, len); + string = strndup((const char *) option, len); if (!string) return -ENOMEM; |