]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: make sure we can deal with a single trailing NUL byte in the hostname
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Sep 2015 21:35:18 +0000 (23:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 30 Sep 2015 21:35:18 +0000 (23:35 +0200)
Fixes #1337

src/libsystemd-network/sd-dhcp-lease.c

index aa07846693dcdddc6e030a07198c1ce0bff2c141..df3d8e6e3c7ce95d10ded41106f5f1ec31dd04e5 100644 (file)
@@ -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;