patch to fix the fuction nl_addr_cmp_prefix?

Malte Langermann mlangermann at radiodata.biz
Tue Jan 29 05:32:11 EST 2013


Am 17.01.2013 20:59, schrieb Thomas Graf:
> On 01/17/13 at 04:27pm, Zhou, Jingting wrote:
>> Hey all, we found a bug in the function nl_addr_cmp_prefix in the file lib/addr.c. The function doesn't handle the cases when the prefixes of the two addresses are not multiples of 8. Attached is a git patch to fix this. Can someone maintaining this apply the patch so we don't have to apply it in our side? Thanks~
> I'd be happy to apply the patch but there doesn't seem to be
> a patch attached. Please resend with the patch inlined for
> easy review and commenting.
>
>

Hi,

here is a patch to current git tree

Greets,
Malte.

Index: lib/addr.c
===================================================================
--- lib/addr.c
+++ lib/addr.c
@@ -525,8 +525,8 @@
         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);


-- 
Malte Langermann - Softwareentwicklung

---------------------------------------------------------------------
RADIODATA GmbH
Ringbahnstraße 32-34
12099 Berlin

Telefon Zentrale:      +49 (0)30 756 81 -3
Fax:                   +49 (0)30 756 81 -599
e- Mail:               mlangermann at radiodata.biz
Homepage:              www.radiodata.biz

USt_IdNr.:             DE 195663499
WEEE-Reg.-Nr.:         DE 63967380


Sitz der Gesellschaft: Berlin
Registergericht:       Amtsgericht Charlottenburg HRB  Nr.: 67865
Geschäftsführer:       Hans-Joachim Langermann




More information about the libnl mailing list