[netfilter-cvslog] r4217 - in trunk/libnfnetlink: include/libnfnetlink src

laforge at netfilter.org laforge at netfilter.org
Sun Aug 7 00:17:22 CEST 2005


Author: laforge at netfilter.org
Date: 2005-08-07 00:17:20 +0200 (Sun, 07 Aug 2005)
New Revision: 4217

Modified:
   trunk/libnfnetlink/include/libnfnetlink/libnfnetlink.h
   trunk/libnfnetlink/src/libnfnetlink.c
Log:
- add nfnl_fd() accessor function
- export nfnl_check_attributes()
- fix segfault (nfnlh->cb assignment missing)
- memset() the nfattr array in nfnl_parse_attr()
- fix endless loop in msg_next()


Modified: trunk/libnfnetlink/include/libnfnetlink/libnfnetlink.h
===================================================================
--- trunk/libnfnetlink/include/libnfnetlink/libnfnetlink.h	2005-08-06 21:13:04 UTC (rev 4216)
+++ trunk/libnfnetlink/include/libnfnetlink/libnfnetlink.h	2005-08-06 22:17:20 UTC (rev 4217)
@@ -35,6 +35,8 @@
 	struct nfnl_callback 	*cb;	/* array of callbacks */
 };
 
+extern int nfnl_fd(struct nfnl_handle *h);
+
 /* get a new library handle */
 extern int nfnl_open(struct nfnl_handle *, u_int8_t, u_int8_t, unsigned int);
 extern int nfnl_close(struct nfnl_handle *);
@@ -69,6 +71,9 @@
 extern struct nfattr *nfnl_parse_hdr(const struct nfnl_handle *nfnlh, 
 				     const struct nlmsghdr *nlh,
 				     struct nfgenmsg **genmsg);
+extern int nfnl_check_attributes(const struct nfnl_handle *nfnlh,
+				 const struct nlmsghdr *nlh,
+				 struct nfattr *tb[]);
 extern struct nlmsghdr *nfnl_get_msg_first(struct nfnl_handle *h,
 					   const unsigned char *buf,
 					   size_t len);

Modified: trunk/libnfnetlink/src/libnfnetlink.c
===================================================================
--- trunk/libnfnetlink/src/libnfnetlink.c	2005-08-06 21:13:04 UTC (rev 4216)
+++ trunk/libnfnetlink/src/libnfnetlink.c	2005-08-06 22:17:20 UTC (rev 4217)
@@ -54,6 +54,11 @@
 	}
 }
 
+int nfnl_fd(struct nfnl_handle *h)
+{
+	return h->fd;
+}
+
 /**
  * nfnl_open - open a netlink socket
  *
@@ -107,6 +112,7 @@
 	nfnlh->seq = time(NULL);
 	nfnlh->subsys_id = subsys_id;
 	nfnlh->cb_count = cb_count;
+	nfnlh->cb = cb;
 
 	return 0;
 }
@@ -530,6 +536,8 @@
  */
 int nfnl_parse_attr(struct nfattr *tb[], int max, struct nfattr *nfa, int len)
 {
+	memset(tb, 0, sizeof(struct nfattr *) * max);
+
 	while (NFA_OK(nfa, len)) {
 		if (nfa->nfa_type <= max)
 			tb[nfa->nfa_type-1] = nfa;
@@ -610,7 +618,7 @@
 	/* if last header in handle not inside this buffer, 
 	 * drop reference to last header */
 	if (!h->last_nlhdr ||
-	    (unsigned char *)h->last_nlhdr > (buf + len)  ||
+	    (unsigned char *)h->last_nlhdr >= (buf + len)  ||
 	    (unsigned char *)h->last_nlhdr < buf) {
 		h->last_nlhdr = NULL;
 		return NULL;
@@ -654,8 +662,9 @@
 	return 0;
 }
 
-static int nfnl_check_attributes(struct nfnl_handle *h, struct nlmsghdr *nlh,
-				 struct nfattr *nfa[])
+int nfnl_check_attributes(const struct nfnl_handle *h,
+			 const struct nlmsghdr *nlh,
+			 struct nfattr *nfa[])
 {
 	int min_len;
 	u_int8_t type = NFNL_MSG_TYPE(nlh->nlmsg_type);




More information about the netfilter-cvslog mailing list