From 8ebb017a10cd85406ddf5ab60d8ef1f56df526ff Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 12 Apr 2006 08:38:35 +0000 Subject: [PATCH 1/1] 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. --- THANKS | 1 + src/netutl.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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++; } -- 2.20.1