diff options
author | Thomas Haller <thaller@redhat.com> | 2018-12-15 00:45:46 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-19 16:18:57 +0100 |
commit | 2b8434ea4640454ff27e2312545c8f593681dd21 (patch) | |
tree | 9916d4b9ce66694aa59d1937e9a9a89b8cc221cf | |
parent | 1d0b07bcfcf9e8b6c265e05d012d709a8efd2057 (diff) | |
download | NetworkManager-2b8434ea4640454ff27e2312545c8f593681dd21.tar.gz |
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.
https://github.com/systemd/systemd/commit/c24b68216222156a45c5a8a918e7a44c144e9555
-rw-r--r-- | src/systemd/src/libsystemd-network/network-internal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/systemd/src/libsystemd-network/network-internal.c b/src/systemd/src/libsystemd-network/network-internal.c index f03a30f4b3..cee1085312 100644 --- a/src/systemd/src/libsystemd-network/network-internal.c +++ b/src/systemd/src/libsystemd-network/network-internal.c @@ -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; } |