From: Luca Boccassi Date: Wed, 8 Jul 2026 09:57:39 +0000 (+0100) Subject: sd-device: check fd validity before using in sendmsg in test X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7967b6b6d5b15aeba8d6d36e08695afe416f4428;p=thirdparty%2Fsystemd.git sd-device: check fd validity before using in sendmsg in test CID#1663676 Follow-up for 7003a9bf098869e5622fe5d863199910afcdda6d --- diff --git a/src/libsystemd/sd-device/test-sd-device-monitor.c b/src/libsystemd/sd-device/test-sd-device-monitor.c index c4034d27c70..ea8fa880260 100644 --- a/src/libsystemd/sd-device/test-sd-device-monitor.c +++ b/src/libsystemd/sd-device/test-sd-device-monitor.c @@ -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);