Fix a bug in handling prefixlengths that are not a multiple of 4.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 12 Apr 2006 08:38:35 +0000 (08:38 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 12 Apr 2006 08:38:35 +0000 (08:38 +0000)
Thanks to Sven-Haegar Koch for spotting the bug and providing the fix.

THANKS
src/netutl.c

diff --git a/THANKS b/THANKS
index 02cd090..21176e2 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -24,6 +24,7 @@ We would like to thank the following people for their contributions to tinc:
 * Paul Littlefield
 * Robert van der Meulen
 * Scott Lamb
 * Paul Littlefield
 * Robert van der Meulen
 * Scott Lamb
+* Sven-Haegar Koch
 * Teemu Kiviniemi
 * Tonnerre Lombard
 * Wessel Dankers
 * Teemu Kiviniemi
 * Tonnerre Lombard
 * Wessel Dankers
index 535e370..d842627 100644 (file)
@@ -257,7 +257,7 @@ void mask(void *va, int masklen, int len)
        masklen %= 8;
 
        if(masklen)
        masklen %= 8;
 
        if(masklen)
-               a[i++] &= (0x100 - (1 << masklen));
+               a[i++] &= (0x100 - (1 << (8 - masklen)));
 
        for(; i < len; i++)
                a[i] = 0;
 
        for(; i < len; i++)
                a[i] = 0;
@@ -275,7 +275,7 @@ void maskcpy(void *va, const void *vb, int masklen, int len)
                a[i] = b[i];
 
        if(m) {
                a[i] = b[i];
 
        if(m) {
-               a[i] = b[i] & (0x100 - (1 << m));
+               a[i] = b[i] & (0x100 - (1 << (8 - m)));
                i++;
        }
 
                i++;
        }