]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: prepare buffer for dropping unexpected message
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 16 Apr 2025 19:47:49 +0000 (04:47 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 17 Apr 2025 00:52:17 +0000 (01:52 +0100)
Follow-up for c7460cce79fd358f2745bd390bd2e7ded450ee62 (v219).

Fixes #35654.

src/libsystemd/sd-netlink/netlink-socket.c

index 9d2b3984c2b11dd6271a7e3995e6b57d32816c5f..5959959f4271c2c66ea14051451dc2bf930bc3ca 100644 (file)
@@ -181,6 +181,12 @@ static int socket_recv_message(int fd, void *buf, size_t buf_size, uint32_t *ret
                 log_debug("sd-netlink: ignoring message from PID %"PRIu32, sender.nl.nl_pid);
 
                 if (peek) {
+                        _cleanup_free_ uint8_t *b = new(uint8_t, n);
+                        if (!b)
+                                return -ENOMEM;
+
+                        iov = IOVEC_MAKE(b, n);
+
                         /* drop the message */
                         n = recvmsg_safe(fd, &msg, 0);
                         if (n < 0)