Package: packit
Version: 1.0-2
Severity: important
Tags: patch

The package source allocates 17 bytes to strings intended
for hardware addresses, where in fact 18 are needed due
to the trailing null-character. The code is assigning a value
to hwadd[17], so errors do happen. Patches are included.

Please observe, that these two updating patches are conceived
together with a new patch submitted to #652510, so I ask the
maintainer to attend to both bugs. Taken together, the set of
three patches were instrumental in debugging the package rarpd.

Best regards,
  Mats Erik Andersson, DM
>From 1523448405c42d09079ec4a15a8f839657f0d14b Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <[email protected]>
Date: Mon, 3 Jun 2013 23:03:18 +0200
Subject: [PATCH 1/3] Off-by-one string error.

Strings for hardware addresses are allocated
with 17 characters only, neglecting the trailing
null-character.

Remove tabs for better readability.
---
 src/inject_defs.h     | 10 +++++-----
 src/print_arp_hdr.c   |  4 ++--
 src/print_injection.c |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/inject_defs.h b/src/inject_defs.h
index b2c4774..e9a56cf 100644
--- a/src/inject_defs.h
+++ b/src/inject_defs.h
@@ -132,9 +132,9 @@ struct enethdr_opts
     u_int16_t rand_d_addr;
 
     u_int8_t *s_addr;                   /* source ethernet address string */
-    u_int8_t shw_addr[17];
+    u_int8_t shw_addr[18];
     u_int8_t *d_addr;                   /* destination ethernet address string */
-    u_int8_t dhw_addr[17];
+    u_int8_t dhw_addr[18];
 } ehdr_o;
 
 struct arphdr_opts
@@ -153,8 +153,8 @@ struct arphdr_opts
     u_int8_t *r_eaddr;                  /* receiver ethernet address */
     u_int16_t rand_r_eaddr;
 
-    u_int8_t shw_addr[17];
-    u_int8_t rhw_addr[17];
+    u_int8_t shw_addr[18];
+    u_int8_t rhw_addr[18];
 } ahdr_o;
 
 libnet_t *pkt_d;
@@ -174,7 +174,7 @@ u_int16_t payload_len;
 u_int8_t *payload;
 u_int8_t hex_payload;
 u_int8_t *s_d_port;
-u_int8_t hwaddr_p[17];
+u_int8_t hwaddr_p[18];
 u_int8_t rawip;
 
 struct timeval bf_pcap;
diff --git a/src/print_arp_hdr.c b/src/print_arp_hdr.c
index 36c3fb8..24f52d2 100644
--- a/src/print_arp_hdr.c
+++ b/src/print_arp_hdr.c
@@ -39,11 +39,11 @@ print_arp_hdr(u_int8_t *packet)
     arp_hw_t = retrieve_arp_hw_type(htons(ahdr->ar_hrd));
 
     fprintf(stdout, "ARP header:  Type: %s(%d)\n", arp_t, htons(ahdr->ar_op));
-    fprintf(stdout, "\t     Hardware Format: %s  Length: %d\n", 
+    fprintf(stdout, "     Hardware Format: %s  Length: %d\n",
         arp_hw_t, 
 	ahdr->ar_hln);
     
-    fprintf(stdout, "\t     Protocol Format: %d  Length: %d\n", 
+    fprintf(stdout, "     Protocol Format: %d  Length: %d\n",
         ahdr->ar_pro, 
 	ahdr->ar_pln);
 
diff --git a/src/print_injection.c b/src/print_injection.c
index e019fca..a1d8cd8 100644
--- a/src/print_injection.c
+++ b/src/print_injection.c
@@ -179,11 +179,11 @@ print_injection_details()
 	arp_t = retrieve_arp_type(ahdr_o.op_type);
 
 	fprintf(stdout, "ARP header:  Type: %s(%d)\n", arp_t, ahdr_o.op_type);
-	fprintf(stdout, "\t     Sender:  Protocol Address: %s  Hardware Address: %s\n",
+	fprintf(stdout, "     Sender:  Protocol Address: %s  Hardware Address: %.17s\n",
 	    ahdr_o.s_paddr,
 	    ahdr_o.shw_addr); 
 	
-	fprintf(stdout, "\t     Target:  Protocol Address: %s  Hardware Address: %s\n",
+	fprintf(stdout, "     Target:  Protocol Address: %s  Hardware Address: %.17s\n",
 	    ahdr_o.r_paddr,
 	    ahdr_o.rhw_addr); 
 
-- 
1.8.1

>From 9517bdefdaf9be9b5905b2f11f0766d5a52a8630 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <[email protected]>
Date: Thu, 27 Jun 2013 11:34:37 +0200
Subject: [PATCH 2/3] Allow contemporary autotools.

---
 configure.in    | 2 +-
 src/Makefile.am | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index 49edd02..5295a0b 100644
--- a/configure.in
+++ b/configure.in
@@ -25,7 +25,7 @@ dnl Copyright (c) 2002-2003 Darren Bounds
 dnl All rights reserved.
 
 AC_INIT(src/main.c)
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS(config.h)
 PACKIT_VERSION=`cat VERSION`
 AC_MSG_RESULT(beginning auto-configuration process for packit-$PACKIT_VERSION...)
 AM_INIT_AUTOMAKE(packit, $PACKIT_VERSION)
diff --git a/src/Makefile.am b/src/Makefile.am
index 4ff931c..2af09a9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,7 +61,6 @@ packit_LDFLAGS=
 INCLUDES=@INCLUDES@
 
 all:
-	#strip @BINS@
 	cp @BINS@ $(top_srcdir)
 
 clean:
-- 
1.8.1

Reply via email to