From 9bfa2ee5e4440f2acc79649d1a40a91e36f440df Mon Sep 17 00:00:00 2001 From: laforge Date: Fri, 14 Nov 2003 19:19:59 +0000 Subject: check if messages are really coming from kernel (nl_pid == 0) --- ulogd/libipulog/libipulog.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ulogd/libipulog/libipulog.c') diff --git a/ulogd/libipulog/libipulog.c b/ulogd/libipulog/libipulog.c index 0b82fee..b396829 100644 --- a/ulogd/libipulog/libipulog.c +++ b/ulogd/libipulog/libipulog.c @@ -1,5 +1,5 @@ /* - * libipulog.c, $Revision: 1.10 $ + * libipulog.c, $Revision: 1.11 $ * * netfilter ULOG userspace library. * @@ -21,7 +21,7 @@ * This library is still under development, so be aware of sudden interface * changes * - * $Id: libipulog.c,v 1.10 2002/07/30 07:04:12 laforge Exp $ + * $Id: libipulog.c,v 1.11 2003/05/04 10:00:10 laforge Exp $ */ #include @@ -78,24 +78,24 @@ ipulog_netlink_recvfrom(const struct ipulog_handle *h, addrlen = sizeof(h->peer); status = recvfrom(h->fd, buf, len, 0, (struct sockaddr *)&h->peer, &addrlen); - if (status < 0) - { + if (status < 0) { ipulog_errno = IPULOG_ERR_RECV; return status; } - if (addrlen != sizeof (h->peer)) - { + if (addrlen != sizeof (h->peer)) { ipulog_errno = IPULOG_ERR_RECV; return -1; } - if (status == 0) - { + if (h->peer.nl_pid != 0) { + ipulog_errno = IPULOG_ERR_RECV; + return -1; + } + if (status == 0) { ipulog_errno = IPULOG_ERR_NLEOF; return -1; } nlh = (struct nlmsghdr *)buf; - if (nlh->nlmsg_flags & MSG_TRUNC || status > len) - { + if (nlh->nlmsg_flags & MSG_TRUNC || status > len) { ipulog_errno = IPULOG_ERR_TRUNC; return -1; } -- cgit v1.2.3