From: Zbigniew Jędrzejewski-Szmek Date: Wed, 27 Feb 2019 13:15:29 +0000 (+0100) Subject: networkd: fix memleak when the same NetDev is specified twice X-Git-Tag: v242-rc1~233^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83ec4592760db3dc35f0843b9f1e03624a792e9e;p=thirdparty%2Fsystemd.git networkd: fix memleak when the same NetDev is specified twice hashmap_put() returns 0 if the (key, value) pair is already present in the hashmap, and -EEXIST if the key exists, but the value is different. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13433 --- diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index b413abacff7..2d42f0d742e 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -728,13 +728,14 @@ int config_parse_stacked_netdev(const char *unit, return log_oom(); r = hashmap_put(*h, name, INT_TO_PTR(kind)); - if (r < 0) { + if (r < 0) log_syntax(unit, LOG_ERR, filename, line, r, - "Cannot add NetDev '%s' to network, ignoring assignment: %m", rvalue); - return 0; - } - - name = NULL; + "Cannot add NetDev '%s' to network, ignoring assignment: %m", name); + else if (r == 0) + log_syntax(unit, LOG_DEBUG, filename, line, r, + "NetDev '%s' specified twice, ignoring.", name); + else + name = NULL; return 0; } diff --git a/test/fuzz/fuzz-network-parser/oss-fuzz-13433 b/test/fuzz/fuzz-network-parser/oss-fuzz-13433 new file mode 100644 index 00000000000..1aef8b7d83b Binary files /dev/null and b/test/fuzz/fuzz-network-parser/oss-fuzz-13433 differ