Thread (4 messages) 4 messages, 3 authors, 2009-07-30

Re: [PATCH] [IPV4]: Buffer overflow

From: Roel Kluin <hidden>
Date: 2009-07-30 09:44:04
Subsystem: networking [general], networking [ipv4/ipv6], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern, Ido Schimmel, Linus Torvalds

If arp_format_neigh_entry() can be called with n->dev->addr_len == 0, then a
write to hbuffer[-1] occurs.

Signed-off-by: Roel Kluin <redacted>
---
Op 30-07-09 00:02, Jarek Poplawski schreef:
Roel Kluin wrote, On 07/29/2009 12:52 PM:
quoted
-	hbuffer[--k] = 0;
+	if (k != 0)
+		hbuffer[--k] = 0;

I guess for k == 0 we need hbuffer[0] = 0 too.

Jarek P.
Thanks, updated patch below.
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index c29d75d..090e999 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1304,7 +1304,9 @@ static void arp_format_neigh_entry(struct seq_file *seq,
 		hbuffer[k++] = hex_asc_lo(n->ha[j]);
 		hbuffer[k++] = ':';
 	}
-	hbuffer[--k] = 0;
+	if (k != 0)
+		--k;
+	hbuffer[k] = 0;
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	}
 #endif
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help