]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
mask bits to be checked in ot_net
authorDirk Engling <erdgeist@erdgeist.org>
Fri, 29 Mar 2024 02:58:23 +0000 (03:58 +0100)
committerDirk Engling <erdgeist@erdgeist.org>
Fri, 29 Mar 2024 02:58:23 +0000 (03:58 +0100)
ot_accesslist.c

index 181c8f00fa27ec21d604595b546408f38b4944e6..1badc254175d0827dfbd29e4b6fd00d30463d243 100644 (file)
@@ -385,10 +385,10 @@ void accesslist_cleanup( void ) {
 #endif
 
 int address_in_net( const ot_ip6 address, const ot_net *net ) {
-  int bits = net->bits;
+  int bits = net->bits, checkbits = ( 0x7f00 >> ( bits & 7 ));
   int result = memcmp( address, &net->address, bits >> 3 );
   if( !result && ( bits & 7 ) )
-    result = ( ( 0x7f00 >> ( bits & 7 ) ) & address[bits>>3] ) - net->address[bits>>3];
+    result = ( checkbits & address[bits>>3] ) - ( checkbits & net->address[bits>>3]);
   return result == 0;
 }