From: Jaehyun Kim Date: Tue, 18 Feb 2025 03:02:41 +0000 (+0900) Subject: Fix to handle values ​​0 and below when converting prefix_len X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen;p=platform%2Fcore%2Fapi%2Fconnection.git Fix to handle values ​​0 and below when converting prefix_len Change-Id: I30b4922c12277aaa08877af7eb585c52658edb95 Signed-off-by: Jaehyun Kim --- diff --git a/src/connection_profile.c b/src/connection_profile.c index 738eda7..a45fba1 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -292,6 +292,9 @@ 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) { + if (prefix_len <= 0) + return 0; + return (prefix_len & ~31) ? 0xFFFFFFFFu : htonl(0xFFFFFFFFu << (32 - prefix_len)); }