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:
parent
3772cfde03
commit
83ec459276
@ -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;
|
||||
}
|
||||
|
BIN
test/fuzz/fuzz-network-parser/oss-fuzz-13433
Normal file
BIN
test/fuzz/fuzz-network-parser/oss-fuzz-13433
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user