conntrack-tools bugs
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20150527180914.GA3685@salvia
Please see the attached patches.
Thanks,
P.
Quoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · Paul Aitken
Pablo, I found a couple of bugs in conntrack-tools.
I could clone the git repo and fix them or submit a patch. What's the right process?
Quoted 8 lines
Please, send patches to [email protected]
I need that they apply through git am, ie. you have to generate it with git format-patch.
Include a title and a description. Thanks.
From
af1d3f66cf4fac3d2d5454dd11263c6f89d655c5Mon Sep 17 00:00:00 2001
From: Paul Aitken <[email protected]>
Date: Thu, 28 May 2015 16:25:20 +0100
Subject: [PATCH 1/3] Fix two issues with memset
[src/expect.c:57]: (warning) The 2nd memset() argument '4294967295' doesn't fit into an 'unsigned char'.
[src/expect.c:132]: (warning) The 2nd memset() argument '4294967295' doesn't fit into an 'unsigned char'.
memset fills bytes, not ulongs - so the second parameter (the fill value) has to be a byte.
Additionally, the second memset wasn't using the loop value as an array offset.
--- src/expect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/expect.c +2 -2
@@ -54,7 +54,7 @@ cthelper_expect_init(struct nf_expect *exp, struct nf_conntrack *master,nfct_set_attr (expected,ATTR_IPV6_SRC , saddr->ip6);for (i=0 ; i<4 ; i++) -memset (&addr[i],0xffffffff ,sizeof (uint32_t )); +memset (&addr[i],0xff ,sizeof (uint32_t ));nfct_set_attr_u8 (mask,ATTR_L3PROTO ,AF_INET6 );nfct_set_attr (mask,ATTR_IPV6_SRC , addr);
@@ -129,7 +129,7 @@ cthelper_expect_init(struct nf_expect *exp, struct nf_conntrack *master,nfct_set_attr (expected,ATTR_IPV6_DST , daddr->ip6);for (i=0 ; i<4 ; i++) -memset (addr,0xffffffff ,sizeof (uint32_t )); +memset (&addr[i],0xff ,sizeof (uint32_t ));nfct_set_attr (mask,ATTR_IPV6_DST , addr);break ;
Signature · 1 line
1.9.1
Quoted 1 line
From
395c8b6ce66dfaca6d3d85611a174ad2b026a241Mon Sep 17 00:00:00 2001
From: Paul Aitken <[email protected]>
Date: Thu, 28 May 2015 16:34:33 +0100
Subject: [PATCH 2/3] Optimise nfq_queue_cb
ct and myct have both already been checked for non-NULL, so there's no need to check either of them again here.
--- src/cthelper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
src/cthelper.c +3 -5
@@ -325,14 +325,12 @@ static int nfq_queue_cb(const struct nlmsghdr *nlh, void *data)if (pkt_verdict_issue (helper, myct, queue_num, id, verdict, pktb) <0 ) goto err_pktb; -if (ct !=NULL ) -nfct_destroy (ct); +nfct_destroy (ct);if (myct->exp !=NULL )nfexp_destroy (myct->exp); -if (myct && myct->priv_data !=NULL ) +if (myct->priv_data !=NULL )free (myct->priv_data); -if (myct !=NULL ) -free (myct); +free (myct);return MNL_CB_OK ; err_pktb:
Signature · 1 line
1.9.1
Quoted 1 line
From
d81010b4b9a7601b9503aee09bc5e2b280b8e097Mon Sep 17 00:00:00 2001
From: Paul Aitken <[email protected]>
Date: Thu, 28 May 2015 16:35:19 +0100
Subject: [PATCH 3/3] remove unused 'numbytes'
'numbytes' isn't used and can be removed.
--- src/local.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
src/local.c +1 -2
@@ -117,11 +117,10 @@ void local_client_destroy(int fd)int do_local_client_step (int fd,void (*process)(char *buf)) { -int numbytes;char buf[1024 ];memset (buf,0 ,sizeof (buf)); -while ((numbytes =recv (fd, buf,sizeof (buf)-1 ,0 )) >0 ) { +while (recv (fd, buf,sizeof (buf)-1 ,0 ) >0 ) { buf[sizeof (buf)-1 ] ='\0' ;if (process)process (buf);
Signature · 1 line
1.9.1