tlm-config: Change type for comparison of identical types 41/320541/1 accepted/tizen/unified/20241120.162215 accepted/tizen/unified/x/20241218.032857 accepted/tizen/unified/x/asan/20241224.004633
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 18 Nov 2024 06:46:19 +0000 (15:46 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 18 Nov 2024 07:15:55 +0000 (16:15 +0900)
Change type of variable 'i' and 'j' to gsize for comparison of idential types.
Two variables was int instead of gsize, but the variable performing comparison operation
with the corresponding values have the type of gsize.
In this case, gsize (unsinged) has big max value than max value of int (signed).
Therefore, it can cause wrong result when performing comparison operation.
For example, 'for (int i = 0; i < gsize value; i++)' can cause overflow of 'i',
so it would result in infinite loops.

Change-Id: I48aac1081b543a88e0ebb3aa19520d3cc56a8d7b
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/tlm-config.c

index dcd2c650764ff036f3c898b83f0b7d52647061de..d3b1931326b63e83efb097842bbde7e176047bff 100755 (executable)
@@ -117,7 +117,8 @@ _load_config (TlmConfig *self)
     GError *err = NULL;
     gchar **groups = NULL;
     gsize n_groups = 0;
-    int i,j;
+    gsize i = 0;
+    gsize j = 0;
     GKeyFile *settings = g_key_file_new ();
 
     const gchar * const *sysconfdirs;