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

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
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-02-27 14:15:29 +01:00
parent 3772cfde03
commit 83ec459276
2 changed files with 7 additions and 6 deletions

View File

@ -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;
}

Binary file not shown.