ippool: Private address check was incorrect
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 12 Jun 2013 08:02:56 +0000 (11:02 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 12 Jun 2013 12:53:41 +0000 (15:53 +0300)
Fixes BMC#25993

src/ippool.c

index 52446cec1b8b7c9c8963ca13f585cd89c589f3fc..531745eb05baf7423b9f8368a2b73c1b4c7ce76f 100644 (file)
@@ -223,21 +223,13 @@ static struct address_info *lookup_info(int index, uint32_t start)
 
 static connman_bool_t is_private_address(uint32_t address)
 {
-       uint32_t val;
+       unsigned int a, b;
 
-       if ((address & 0xff000000) == block_24_bits)
-               return TRUE;
-
-       if ((address & 0xffff0000) == block_20_bits) {
-               val = (address & 0x00ff0000) >> 16;
-
-               if (val < 16 || val > 31)
-                       return FALSE;
-
-               return TRUE;
-       }
+       a = (address & 0xff000000) >> 24;
+       b = (address & 0x00ff0000) >> 16;
 
-       if ((address & 0xffffff00) == block_16_bits)
+       if (a == 10 || (a == 192 && b == 168) ||
+                                       (a == 172 && (b >= 16 && b <= 31)))
                return TRUE;
 
        return FALSE;