pknlusr: do not treat recv return value of zero as an error

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>
This commit is contained in:
Jeremy Sowden
2020-10-25 14:15:53 +01:00
committed by Jan Engelhardt
parent b0a1aacd4b
commit 3c120ef5f1

View File

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