aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-03-24 13:47:05 +0100
committerGitHub <noreply@github.com>2019-03-24 13:47:05 +0100
commitfd7887da006a0d64dc4e1eeb6c0c9ef197a5e500 (patch)
tree1dffbca744fda5740aae92c87ef9176789c456c8
parentMerge pull request #11602 from vesajaaskelainen/dbus-reboot-with-parameters (diff)
parentfuzz: add testcases for the bug in condition_free_list_type() (diff)
downloadsystemd-fd7887da006a0d64dc4e1eeb6c0c9ef197a5e500.tar.xz
systemd-fd7887da006a0d64dc4e1eeb6c0c9ef197a5e500.zip
Merge pull request #12087 from yuwata/fix-condition-free-list
util: fix condition_free_list_type()
-rw-r--r--src/network/netdev/netdev.h2
-rw-r--r--src/network/networkd-network.h2
-rw-r--r--src/shared/condition.c16
-rw-r--r--src/udev/net/link-config.h2
-rw-r--r--test/fuzz/fuzz-link-parser/oss-fuzz-138784
-rw-r--r--test/fuzz/fuzz-link-parser/oss-fuzz-13882bin0 -> 2015 bytes
-rw-r--r--test/fuzz/fuzz-netdev-parser/oss-fuzz-13884bin0 -> 449 bytes
-rw-r--r--test/fuzz/fuzz-netdev-parser/oss-fuzz-13886bin0 -> 47998 bytes
-rw-r--r--test/fuzz/fuzz-network-parser/oss-fuzz-13888bin0 -> 56 bytes
9 files changed, 15 insertions, 11 deletions
diff --git a/src/network/netdev/netdev.h b/src/network/netdev/netdev.h
index 3c6990236fe..ad4dd2e2b0d 100644
--- a/src/network/netdev/netdev.h
+++ b/src/network/netdev/netdev.h
@@ -81,7 +81,7 @@ typedef struct NetDev {
char *filename;
- Condition *conditions;
+ LIST_HEAD(Condition, conditions);
NetDevState state;
NetDevKind kind;
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 7211aee8c68..852144da3c0 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -97,7 +97,7 @@ struct Network {
char **match_driver;
char **match_type;
char **match_name;
- Condition *conditions;
+ LIST_HEAD(Condition, conditions);
char *description;
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 69d65fffbce..32a90bcea36 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -77,17 +77,17 @@ void condition_free(Condition *c) {
free(c);
}
-Condition* condition_free_list_type(Condition *first, ConditionType type) {
- Condition *c, *n, *r = NULL;
+Condition* condition_free_list_type(Condition *head, ConditionType type) {
+ Condition *c, *n;
- LIST_FOREACH_SAFE(conditions, c, n, first)
- if (type < 0 || c->type == type)
+ LIST_FOREACH_SAFE(conditions, c, n, head)
+ if (type < 0 || c->type == type) {
+ LIST_REMOVE(conditions, head, c);
condition_free(c);
- else if (!r)
- r = c;
+ }
- assert(type >= 0 || !r);
- return r;
+ assert(type >= 0 || !head);
+ return head;
}
static int condition_test_kernel_command_line(Condition *c) {
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
index 5dfe5b59b88..efe5f2ce3a9 100644
--- a/src/udev/net/link-config.h
+++ b/src/udev/net/link-config.h
@@ -40,7 +40,7 @@ struct link_config {
char **match_driver;
char **match_type;
char **match_name;
- Condition *conditions;
+ LIST_HEAD(Condition, conditions);
char *description;
struct ether_addr *mac;
diff --git a/test/fuzz/fuzz-link-parser/oss-fuzz-13878 b/test/fuzz/fuzz-link-parser/oss-fuzz-13878
new file mode 100644
index 00000000000..dbb2abecb05
--- /dev/null
+++ b/test/fuzz/fuzz-link-parser/oss-fuzz-13878
@@ -0,0 +1,4 @@
+[Match]
+KernelVersion=t
+Virtualization=q
+KernelVersion= \ No newline at end of file
diff --git a/test/fuzz/fuzz-link-parser/oss-fuzz-13882 b/test/fuzz/fuzz-link-parser/oss-fuzz-13882
new file mode 100644
index 00000000000..7c56ec222d8
--- /dev/null
+++ b/test/fuzz/fuzz-link-parser/oss-fuzz-13882
Binary files differ
diff --git a/test/fuzz/fuzz-netdev-parser/oss-fuzz-13884 b/test/fuzz/fuzz-netdev-parser/oss-fuzz-13884
new file mode 100644
index 00000000000..ce8d713a035
--- /dev/null
+++ b/test/fuzz/fuzz-netdev-parser/oss-fuzz-13884
Binary files differ
diff --git a/test/fuzz/fuzz-netdev-parser/oss-fuzz-13886 b/test/fuzz/fuzz-netdev-parser/oss-fuzz-13886
new file mode 100644
index 00000000000..1230ffe699b
--- /dev/null
+++ b/test/fuzz/fuzz-netdev-parser/oss-fuzz-13886
Binary files differ
diff --git a/test/fuzz/fuzz-network-parser/oss-fuzz-13888 b/test/fuzz/fuzz-network-parser/oss-fuzz-13888
new file mode 100644
index 00000000000..c75fcb4e8a9
--- /dev/null
+++ b/test/fuzz/fuzz-network-parser/oss-fuzz-13888
Binary files differ