From: Lennart Poettering Date: Wed, 30 Sep 2015 21:35:18 +0000 (+0200) Subject: dhcp: make sure we can deal with a single trailing NUL byte in the hostname X-Git-Tag: v227~44^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e989fd9b67f5e19b115e940d397a83e260668763;p=thirdparty%2Fsystemd.git dhcp: make sure we can deal with a single trailing NUL byte in the hostname Fixes #1337 --- diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index aa07846693d..df3d8e6e3c7 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;