diff mbox

[IPV4] : Buffer overflow

Message ID 4A716C13.6030208@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

roel kluin July 30, 2009, 9:46 a.m. UTC
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 <roel.kluin@gmail.com>
---
Op 30-07-09 00:02, Jarek Poplawski schreef:
> Roel Kluin wrote, On 07/29/2009 12:52 PM:

>> -	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.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller July 30, 2009, 8:28 p.m. UTC | #1
From: Roel Kluin <roel.kluin@gmail.com>
Date: Thu, 30 Jul 2009 11:46:59 +0200

> 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 <roel.kluin@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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