Fix converting prefix to netmask 61/319661/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 14 Feb 2025 08:48:42 +0000 (17:48 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 14 Feb 2025 08:48:42 +0000 (17:48 +0900)
When converting a prefix to a netmask,
the existing logic could only handle inputs that were multiples of 8,
so it was modified to handle all inputs.

Change-Id: I5ac440e967b136b581739862b7bd13367fe7ac21
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/connection_profile.c

index 722d2e86260d4572e54bdb525a6d6f9c9e636057..738eda72b085bec77c6175f31c95bb65a961c301 100755 (executable)
@@ -292,7 +292,7 @@ static unsigned char __profile_convert_netmask_to_prefix_len(const char *netmask
 
 static in_addr_t __profile_convert_prefix_len_to_netmask(int prefix_len)
 {
-       return (prefix_len ? (in_addr_t) 0xFFFFFFFFu >> (32 - prefix_len) : 0);
+       return (prefix_len & ~31) ? 0xFFFFFFFFu : htonl(0xFFFFFFFFu << (32 - prefix_len));
 }
 
 //LCOV_EXCL_START