1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-05 09:17:44 +03:00

dhcp: make sure we can deal with a single trailing NUL byte in the hostname

Fixes #1337
This commit is contained in:
Lennart Poettering 2015-09-30 23:35:18 +02:00
parent fe08a30b58
commit e989fd9b67

View 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;