mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 13:30:08 +01:00
systemd: network: don't return allocated buffer of zero length from deserialize_in_addrs()
Imported from systemd:
deserialize_in_addrs() allocates the buffer before trying to parse
the IP address. Since a parsing error is silently ignored, the returned
size might be zero. In such a case we shouldn't return any buffer.
Anyway, there was no leak, because there are only two callers like
r = deserialize_in_addrs(&lease->dns, dns);
which both keep the unused buffer and later release it.
Note that deserialize_in_addrs() doesn't free the pointer before
reassigning the new output. The caller must take care to to pass
"ret" with an allocated buffer that would be leaked when returning
the result.
c24b682162
This commit is contained in:
parent
1d0b07bcfc
commit
2b8434ea46
1 changed files with 1 additions and 1 deletions
|
|
@ -456,7 +456,7 @@ int deserialize_in_addrs(struct in_addr **ret, const char *string) {
|
|||
size++;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(addresses);
|
||||
*ret = size > 0 ? TAKE_PTR(addresses) : NULL;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue