]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
pknlusr: do not treat recv return value of zero as an error
authorJeremy Sowden <jeremy@azazel.net>
Sun, 25 Oct 2020 13:15:53 +0000 (14:15 +0100)
committerJan Engelhardt <jengelh@inai.de>
Sun, 25 Oct 2020 14:01:50 +0000 (15:01 +0100)
A return-value of zero is not an error, so there is no point calling
perror, but since we have not requested and do not expect a zero-length
datagram, we treat it as EOF and exit.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
extensions/pknock/pknlusr.c

index 16a9af917767ad9dfb363013487bc7e0e0bea028..81cfae0f440cdea80d98f74d77e1a7c36c229eb6 100644 (file)
@@ -51,10 +51,12 @@ int main(void)
 
                memset(nlmsg, 0, nlmsg_size);
                status = recv(sock_fd, nlmsg, nlmsg_size, 0);
-               if (status <= 0) {
+               if (status < 0) {
                        perror("recv()");
                        return 1;
                }
+               if (status == 0)
+                       break;
                cn_msg = NLMSG_DATA(nlmsg);
                pknock_msg = (struct xt_pknock_nl_msg *)(cn_msg->data);
                ip = inet_ntop(AF_INET, &pknock_msg->peer_ip, ipbuf, sizeof(ipbuf));