From: Adam Michalski Date: Fri, 29 Nov 2024 10:19:57 +0000 (+0100) Subject: Fix SVACE issue X-Git-Tag: accepted/tizen/unified/20241211.152216~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b2d37baf88adc91ce385327dd306451e3cb8843;p=platform%2Fcore%2Fapi%2Fresource.git Fix SVACE issue WID:12134324 Result of sizeof should not be assigned to 4 byte data type socklen_t is typically a type that represents the length of socket-related structures. It is defined as an integer type, and its size may vary between platforms (e.g., 4 bytes on some systems, 8 bytes on others). The sizeof(sockaddr) expression returns a size of type size_t, which is often 8 bytes on 64-bit platforms. Assigning a size_t value (potentially 8 bytes) to a socklen_t (potentially 4 bytes) might cause truncation, leading to this static analyzer warning. While this is unlikely to cause actual issues in practice (since the size of struct sockaddr_un is typically within the range of socklen_t), the static analyzer points out the theoretical possibility of a mismatch. Change-Id: I1c51d47b742e7cfeaa508a4e1f1906d8b123d3f0 --- diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index 73d4990..decd3a5 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -58,7 +58,7 @@ static int resource_create_and_connect_sock(void) sockaddr.sun_family = AF_UNIX; strncpy(sockaddr.sun_path, SOCK_PATH, strlen(SOCK_PATH) + 1); - len = sizeof(sockaddr); + len = (socklen_t)sizeof(sockaddr); if (connect(sock, (struct sockaddr *)&sockaddr, len) < 0) { _E("[CPU-BOOSTING-PLUGIN] Failed to connect to the resourced module");