[libnetfilter_conntrack] Use union of char buffer and message header to ensure proper byte alignment.

Pablo Neira netfilter-cvslog-bounces at lists.netfilter.org
Wed Jun 18 14:37:51 CEST 2008


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=libnetfilter_conntrack.git;a=commit;h=a47403d558f98368366116bf3aad8a6932671fc6
commit a47403d558f98368366116bf3aad8a6932671fc6
Author:     Fabian Hugelshofer <hugelshofer2006 at gmx.ch>
AuthorDate: Wed Jun 18 14:24:57 2008 +0200
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Wed Jun 18 14:24:57 2008 +0200

    Use union of char buffer and message header to ensure proper byte
    alignment.
    
    Signed-off-by: Fabian Hugelshofer <hugelshofer2006 at gmx.ch>
       via  a47403d558f98368366116bf3aad8a6932671fc6 (commit)
      from  29ce47fc611015a64f66d1ec93c67a9d998f0592 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a47403d558f98368366116bf3aad8a6932671fc6
Author: Fabian Hugelshofer <hugelshofer2006 at gmx.ch>
Date:   Wed Jun 18 14:24:57 2008 +0200

    Use union of char buffer and message header to ensure proper byte
    alignment.
    
    Signed-off-by: Fabian Hugelshofer <hugelshofer2006 at gmx.ch>

-----------------------------------------------------------------------

 src/conntrack/api.c |   20 ++++++++++++--------
 src/expect/api.c    |   10 ++++++----
 2 files changed, 18 insertions(+), 12 deletions(-)
alignment.

Signed-off-by: Fabian Hugelshofer <hugelshofer2006 at gmx.ch>

diff --git a/src/conntrack/api.c b/src/conntrack/api.c
index b1347dc..58efd32 100644
--- a/src/conntrack/api.c
+++ b/src/conntrack/api.c
@@ -563,16 +563,18 @@ int nfct_query(struct nfct_handle *h,
 	       const void *data)
 {
 	size_t size = 4096;	/* enough for now */
-	char buffer[4096];
-	struct nfnlhdr *req = (struct nfnlhdr *) buffer;
+	union {
+		char buffer[size];
+		struct nfnlhdr req;
+	} u;
 
 	assert(h != NULL);
 	assert(data != NULL);
 
-	if (nfct_build_query(h->nfnlssh_ct, qt, data, req, size) == -1)
+	if (nfct_build_query(h->nfnlssh_ct, qt, data, &u.req, size) == -1)
 		return -1;
 
-	return nfnl_query(h->nfnlh, &req->nlh);
+	return nfnl_query(h->nfnlh, &u.req.nlh);
 }
 
 /**
@@ -593,16 +595,18 @@ int nfct_send(struct nfct_handle *h,
 	      const void *data)
 {
 	size_t size = 4096;	/* enough for now */
-	char buffer[4096];
-	struct nfnlhdr *req = (struct nfnlhdr *) buffer;
+	union {
+		char buffer[size];
+		struct nfnlhdr req;
+	} u;
 
 	assert(h != NULL);
 	assert(data != NULL);
 
-	if (nfct_build_query(h->nfnlssh_ct, qt, data, req, size) == -1)
+	if (nfct_build_query(h->nfnlssh_ct, qt, data, &u.req, size) == -1)
 		return -1;
 
-	return nfnl_send(h->nfnlh, &req->nlh);
+	return nfnl_send(h->nfnlh, &u.req.nlh);
 }
 
 
diff --git a/src/expect/api.c b/src/expect/api.c
index eefc294..ab804ca 100644
--- a/src/expect/api.c
+++ b/src/expect/api.c
@@ -507,16 +507,18 @@ int nfexp_query(struct nfct_handle *h,
 	        const void *data)
 {
 	size_t size = 4096;	/* enough for now */
-	char buffer[4096];
-	struct nfnlhdr *req = (struct nfnlhdr *) buffer;
+	union {
+		char buffer[size];
+		struct nfnlhdr req;
+	} u;
 
 	assert(h != NULL);
 	assert(data != NULL);
 
-	if (nfexp_build_query(h->nfnlssh_exp, qt, data, req, size) == -1)
+	if (nfexp_build_query(h->nfnlssh_exp, qt, data, &u.req, size) == -1)
 		return -1;
 
-	return nfnl_query(h->nfnlh, &req->nlh);
+	return nfnl_query(h->nfnlh, &u.req.nlh);
 }
 
 /**



More information about the netfilter-cvslog mailing list