All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libnfnetlink
@ 2006-09-29 12:10 Maik Hentsche
  2006-09-29 14:18 ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: Maik Hentsche @ 2006-09-29 12:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

Hello Pablo, hello readers of the list,
I found another bug in libnfnetlink. The comment of nfnl_recv states, in
case of success 0 is returned. In fact at success the returnvalue of
recvfrom is returned, which is the number of received bytes
(libnfnetlink_recv_comment.patch). The second issue is a little more
serious. The comment states, in case of an error, errno is set when in
fact it is not. I appended a patch for two occurences, but I since I
don't know, in which case addrlen might be != sizeof(peer) and what
peer.nl_pid means (and therefore why it is a problem, if it's not 0)
two error cases without appropriate errno value still exist.

so long
Maik

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: libnfnetlink_recv_errno.patch --]
[-- Type: text/x-patch; name="libnfnetlink_recv_errno.patch", Size: 850 bytes --]

diff -U 3 -b -B -d -i -r -N -x .svn -- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c
--- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c	2006-09-26 10:00:12.000000000 +0200
+++ libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c	2006-09-29 09:50:44.000000000 +0200
@@ -462,8 +462,10 @@
 	assert(len > 0);
 	
 	if (len < sizeof(struct nlmsgerr)
-	    || len < sizeof(struct nlmsghdr))
+	    || len < sizeof(struct nlmsghdr)){
+		errno = ENOBUFS;
 		return -1; 
+	}
 
 	addrlen = sizeof(h->peer);
 	status = recvfrom(h->fd, buf, len, 0, (struct sockaddr *)&peer,	
@@ -478,8 +480,10 @@
 		return -1;
 
 	nlh = (struct nlmsghdr *)buf;
-	if (nlh->nlmsg_flags & MSG_TRUNC || status > len)
+	if (nlh->nlmsg_flags & MSG_TRUNC || status > len){
+		errno = ENOBUFS;
 		return -1;
+	}
 
 	return status;
 }

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: libnfnetlink_recv_comment.patch --]
[-- Type: text/x-patch; name="libnfnetlink_recv_comment.patch", Size: 790 bytes --]

diff -U 3 -b -B -d -i -r -N -x .svn -- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c
--- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c	2006-09-29 09:54:27.000000000 +0200
+++ libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c	2006-09-29 10:17:11.000000000 +0200
@@ -443,8 +443,8 @@
  * that the data is well-formed. Such checkings are done by the parsing
  * functions.
  *
- * On success, 0 is returned. On error, -1 is returned and errno is set
- * appropiately.
+ * On success, the number of bytes received is returned. On error, -1 is
+ * returned and errno is set appropiately.
  *
  * Note that ENOBUFS is returned in case that nfnetlink is exhausted. In
  * that case is possible that the information requested is incomplete.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH] libnfnetlink
@ 2006-10-09 15:07 Maik Hentsche
  2006-10-09 15:14 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 6+ messages in thread
From: Maik Hentsche @ 2006-10-09 15:07 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

Hallo pablo, hello readers of the list,
attached is a patch, that corrects another error in the comments of
libnfnetlink. nfnl_send uses send_to and thus returns the number of
send bytes instead of 0 in case of success. Pardon me for bothering you
with such trivial patches, but I think, as long as the
sgml-documentation isn't finished (I'm working on it), developers using
the lib might need those comments.

so long
Maik


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: libnfnetlink_send_comment.patch --]
[-- Type: text/x-patch; name="libnfnetlink_send_comment.patch", Size: 672 bytes --]

diff -U 3 -b -B -d -i -r -N -x .svn -- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c
--- libnfnetlink-0.0.16-pablo-r1/src/libnfnetlink.c	2006-10-09 16:54:30.000000000 +0200
+++ libnfnetlink-0.0.16-pablo-r1.new/src/libnfnetlink.c	2006-10-09 16:52:43.000000000 +0200
@@ -330,8 +330,8 @@
  * @nfnlh: nfnetlink handler
  * @n: netlink message
  *
- * On success, 0 is returned. On error, -1 is returned and errno is set
- * appropiately.
+ * On success, the number of send bytes is returned. On error, -1 is
+ * returned and errno is set appropiately.
  */
 int nfnl_send(struct nfnl_handle *nfnlh, struct nlmsghdr *n)
 {

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-10-11 10:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-29 12:10 [PATCH] libnfnetlink Maik Hentsche
2006-09-29 14:18 ` Patrick McHardy
2006-10-02 13:47   ` Pablo Neira Ayuso
2006-10-11 10:32     ` Patrick McHardy
  -- strict thread matches above, loose matches on Subject: below --
2006-10-09 15:07 Maik Hentsche
2006-10-09 15:14 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.