kernel-netlink: Actually verify if the netlink message exceeds the buffer size
authorTobias Brunner <tobias@strongswan.org>
Thu, 16 Jul 2015 09:43:44 +0000 (11:43 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 4 Aug 2015 12:15:18 +0000 (14:15 +0200)
It might equal it and that's fine. With MSG_TRUNC we get the actual
message size and can only report an error if we haven't received the
complete message.

src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c

index b0e3103..238de82 100644 (file)
@@ -185,8 +185,8 @@ static ssize_t read_msg(private_netlink_socket_t *this,
                        return -1;
                }
        }
-       len = recv(this->socket, buf, buflen, block ? 0 : MSG_DONTWAIT);
-       if (len == buflen)
+       len = recv(this->socket, buf, buflen, MSG_TRUNC|(block ? 0 : MSG_DONTWAIT));
+       if (len > buflen)
        {
                DBG1(DBG_KNL, "netlink response exceeds buffer size");
                return 0;