From e4443f9bfcc4576e1e8bf6bbb4e5d03db987ada7 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 10 Jul 2019 01:02:07 +0900 Subject: [PATCH] network: fix memleak set_put() does not return -EEXIST. Fixes #12995 and oss-fuzz#15678. --- src/network/networkd-ndisc.c | 11 +++++------ test/fuzz/fuzz-network-parser/oss-fuzz-15678 | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 test/fuzz/fuzz-network-parser/oss-fuzz-15678 diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 851223a8606..78f89e026e4 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -764,6 +764,9 @@ int config_parse_ndisc_black_listed_prefix( continue; } + if (set_contains(network->ndisc_black_listed_prefix, &ip.in6)) + continue; + r = set_ensure_allocated(&network->ndisc_black_listed_prefix, &in6_addr_hash_ops); if (r < 0) return log_oom(); @@ -774,12 +777,8 @@ int config_parse_ndisc_black_listed_prefix( r = set_put(network->ndisc_black_listed_prefix, a); if (r < 0) { - if (r == -EEXIST) - log_syntax(unit, LOG_WARNING, filename, line, r, - "NDISC black listed prefixs is duplicated, ignoring assignment: %s", n); - else - log_syntax(unit, LOG_ERR, filename, line, r, - "Failed to store NDISC black listed prefix '%s', ignoring assignment: %m", n); + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to store NDISC black listed prefix '%s', ignoring assignment: %m", n); continue; } diff --git a/test/fuzz/fuzz-network-parser/oss-fuzz-15678 b/test/fuzz/fuzz-network-parser/oss-fuzz-15678 new file mode 100644 index 00000000000..2a37d5f4559 --- /dev/null +++ b/test/fuzz/fuzz-network-parser/oss-fuzz-15678 @@ -0,0 +1,2 @@ +[IPv6AcceptRA] +BlackList=70:: 70:: \ No newline at end of file -- 2.47.3