]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: allocate read buffer when necessary
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Nov 2022 17:56:42 +0000 (02:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 26 Nov 2022 02:28:27 +0000 (11:28 +0900)
src/libsystemd/sd-netlink/netlink-socket.c
src/libsystemd/sd-netlink/sd-netlink.c

index 103a23270e26e4d4f88df5bb7367d7eb93b764dc..55dc51ab502d56df12e9a7b54a56fc6d1a4e3129 100644 (file)
@@ -255,7 +255,6 @@ int socket_read_message(sd_netlink *nl) {
         int r;
 
         assert(nl);
-        assert(nl->rbuffer);
 
         /* read nothing, just get the pending message size */
         r = socket_recv_message(nl->fd, NULL, 0, NULL, true);
index b99abae64003fa536057c026423529498c9b0d26..1202fe10a55eecdbe21da15d702909dbbe923d14 100644 (file)
@@ -61,10 +61,6 @@ static int netlink_new(sd_netlink **ret) {
                 .serial = (uint32_t) (now(CLOCK_MONOTONIC) % UINT32_MAX) + 1,
         };
 
-        /* We guarantee that the read buffer has at least space for a message header */
-        if (!greedy_realloc((void**) &nl->rbuffer, sizeof(struct nlmsghdr), sizeof(uint8_t)))
-                return -ENOMEM;
-
         *ret = TAKE_PTR(nl);
         return 0;
 }