]> git.ipfire.org Git - thirdparty/systemd.git/commit
network: don't return allocated buffer of zero length from deserialize_in_addrs()
authorThomas Haller <thaller@redhat.com>
Fri, 14 Dec 2018 23:45:46 +0000 (00:45 +0100)
committerThomas Haller <thaller@redhat.com>
Mon, 18 Feb 2019 12:32:06 +0000 (13:32 +0100)
commitc24b68216222156a45c5a8a918e7a44c144e9555
tree6858344a602a3c814da3e4735206afd26c760687
parent1ff3e129aed3aafa1fdc55eab5d568b67d19fd7a
network: don't return allocated buffer of zero length from deserialize_in_addrs()

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.
src/libsystemd-network/network-internal.c