From: Guus Sliepen Date: Wed, 12 Apr 2006 08:38:35 +0000 (+0000) Subject: Fix a bug in handling prefixlengths that are not a multiple of 4. X-Git-Tag: import-tinc-1.1~720 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=8ebb017a10cd85406ddf5ab60d8ef1f56df526ff;p=meshlink Fix a bug in handling prefixlengths that are not a multiple of 4. Thanks to Sven-Haegar Koch for spotting the bug and providing the fix. --- diff --git a/THANKS b/THANKS index 02cd090c..21176e21 100644 --- 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 +* Sven-Haegar Koch * Teemu Kiviniemi * Tonnerre Lombard * Wessel Dankers diff --git a/src/netutl.c b/src/netutl.c index 535e370b..d8426272 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -257,7 +257,7 @@ void mask(void *va, int masklen, int len) masklen %= 8; if(masklen) - a[i++] &= (0x100 - (1 << masklen)); + a[i++] &= (0x100 - (1 << (8 - masklen))); 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] & (0x100 - (1 << m)); + a[i] = b[i] & (0x100 - (1 << (8 - m))); i++; }