]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: check fd validity before using in sendmsg in test 42933/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 8 Jul 2026 09:57:39 +0000 (10:57 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 8 Jul 2026 12:36:32 +0000 (13:36 +0100)
CID#1663676

Follow-up for 7003a9bf098869e5622fe5d863199910afcdda6d

src/libsystemd/sd-device/test-sd-device-monitor.c

index c4034d27c70460c4c988bc52d06c0cb819155c33..ea8fa88026006555df62ebe9035b58ad405f9538 100644 (file)
@@ -8,6 +8,7 @@
 #include "device-monitor-private.h"
 #include "device-private.h"
 #include "device-util.h"
+#include "fd-util.h"
 #include "io-util.h"
 #include "iovec-util.h"
 #include "mountpoint-util.h"
@@ -444,7 +445,9 @@ TEST(sd_device_monitor_receive_bad_properties_off) {
                 .msg_name = &sa,
                 .msg_namelen = sizeof(struct sockaddr_nl),
         };
-        ASSERT_OK_ERRNO(sendmsg(sd_device_monitor_get_fd(monitor_server), &smsg, 0));
+
+        int fd = ASSERT_FD(sd_device_monitor_get_fd(monitor_server));
+        ASSERT_OK_ERRNO(sendmsg(fd, &smsg, 0));
 
         _cleanup_(sd_device_unrefp) sd_device *dev = NULL;
         ASSERT_ERROR(sd_device_monitor_receive(monitor_client, &dev), EAGAIN);