From 87458abbd03b0928b9d2ddd84b7bcb07892450d0 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Thu, 31 Jan 2013 10:59:10 +0100 Subject: [PATCH] Fix mask calculation in nl_addr_cmp_prefix() Signed-off-by: Malte Langermann Signed-off-by: Thomas Graf --- lib/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/addr.c b/lib/addr.c index 806664b..9089be8 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -525,8 +525,8 @@ int nl_addr_cmp_prefix(struct nl_addr *a, struct nl_addr *b) int bytes = len / 8; d = memcmp(a->a_addr, b->a_addr, bytes); - if (d == 0) { - int mask = (1UL << (len % 8)) - 1UL; + if (d == 0 && (len % 8) != 0) { + int mask = (0xFF00 >> (len % 8)) & 0xFF; d = (a->a_addr[bytes] & mask) - (b->a_addr[bytes] & mask); -- 2.40.0