]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix memleak
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Jul 2019 16:02:07 +0000 (01:02 +0900)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Jul 2019 10:27:48 +0000 (12:27 +0200)
set_put() does not return -EEXIST.

Fixes #12995 and oss-fuzz#15678.

src/network/networkd-ndisc.c
test/fuzz/fuzz-network-parser/oss-fuzz-15678 [new file with mode: 0644]

index 851223a8606d0e0ab1ea8b857badafedf87af2b2..78f89e026e4f035e35398145472abbcfb35c0a4f 100644 (file)
@@ -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 (file)
index 0000000..2a37d5f
--- /dev/null
@@ -0,0 +1,2 @@
+[IPv6AcceptRA]
+BlackList=70:: 70::
\ No newline at end of file