]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: fix NULL pointer dereference during deserialization
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 2 May 2023 20:36:36 +0000 (22:36 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 3 May 2023 08:09:53 +0000 (10:09 +0200)
src/core/service.c
test/fuzz/fuzz-manager-serialize/crash-9eec6b7ef6fd5c9568189f9259e6ce0546752085 [new file with mode: 0644]

index c035f4c24e49358cdb332771f3c05c1faf02d01d..2ba7511ad21d979907895db5376091798925e3e0 100644 (file)
@@ -3219,6 +3219,11 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
         } else if (streq(key, "accept-socket")) {
                 Unit *socket;
 
+                if (u->type != UNIT_SOCKET) {
+                        log_unit_debug(u, "Failed to deserialize accept-socket: unit is not a socket");
+                        return 0;
+                }
+
                 r = manager_load_unit(u->manager, value, NULL, NULL, &socket);
                 if (r < 0)
                         log_unit_debug_errno(u, r, "Failed to load accept-socket unit '%s': %m", value);
diff --git a/test/fuzz/fuzz-manager-serialize/crash-9eec6b7ef6fd5c9568189f9259e6ce0546752085 b/test/fuzz/fuzz-manager-serialize/crash-9eec6b7ef6fd5c9568189f9259e6ce0546752085
new file mode 100644 (file)
index 0000000..8bafbb0
--- /dev/null
@@ -0,0 +1,10 @@
+current-job-tmp-dir=/niliclrd,ng
+
+plymo-.sliceuth-quiwt-dir=/niliclrd,ng
+
+plymo-.sliceuth-quiwt-ait.service
+srd2043d7818E@96s
+8582967570742745a94
+accept-socket=runn2043ait.service
+srd2043d7818E@96s
+8582967570742745a94