[Summary for Stephen Hemminger, who's been added to CC:
Martin F. Krafft reported that "ip -r route" segfaults, and I confirmed the
same happening for me. See http://bugs.debian.org/480173]

On Thu, May 08, 2008 at 04:38:27PM +0200, Andreas Henriksson wrote:
[...]
> default via 82.182.69.1 dev wan
[...]
> I'll look closer at the cause when I get a chance!

Oh well, couldn't stay away...

The cause seems to be that the bytes containing the address (gateway)
is (signed) char, and this makes the hash calculation overflow.
hash is unsigned, nht only has 256 slots, and (int)addr[1] == -74 for
me (the part which is "182" in my address I guess).

This silly patch fixes the issue, but it should probably be dealt with
in a better way:


diff --git a/lib/utils.c b/lib/utils.c
index d99deac..81899d0 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -539,7 +539,7 @@ char *resolve_address(const char *addr, int len, int af)
                len = 4;
        }
 
-       hash = addr[len-1] ^ addr[len-2] ^ addr[len-3] ^ addr[len-4];
+       hash = abs(addr[len-1]) ^ abs(addr[len-2]) ^ abs(addr[len-3]) ^ 
abs(addr[len-4]);
 
        for (n = nht[hash]; n; n = n->next) {
                if (n->addr.family == af &&


--
Regards,
Andreas Henriksson
> 
> 
> 
> 
> 



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to