Fix asan build fail 42/238142/3
authorYunjin Lee <yunjin-.lee@samsung.com>
Thu, 9 Jul 2020 02:24:07 +0000 (11:24 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Thu, 9 Jul 2020 02:29:23 +0000 (11:29 +0900)
- How to build with asan:
    $ gbs build -A {architecture} --include-all --extra-packs asan-force-options,asan-build-env --define 'asan 1'

Change-Id: I4c655ac01d9061362a1cf1cc53bc6defe14bc55d
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
test/tc-common.c

index 8fe6ec58018aed7e98acc4c8c54f3b1255474aa7..a7dfbe2bb975aee93cc8bfbef7c915c08f543cf8 100755 (executable)
@@ -4,6 +4,7 @@
 #include <stdarg.h>
 #include <stdbool.h>
 #include <glib.h>
+#include <glib/gprintf.h>
 #include <tc-common.h>
 #include <iniparser.h>
 
@@ -127,26 +128,28 @@ void __print_error_message(char *error_message)
        char *temp = strdup(error_message);
        char *save = NULL;
 
-       char err_type[256] = { 0, };
+       const int err_type_size = 256;
+       char err_type[err_type_size];
+       memset(err_type, 0, err_type_size*sizeof(char));
 
        if (strstr(error_message, "DEPRECATED") != NULL)
-               strncat(err_type, "PRVMGR_ERR_DEPRECATED_PRIVILEGE ", strlen("PRVMGR_ERR_DEPRECATED_PRIVILEGE "));
+               g_strlcat(err_type, "PRVMGR_ERR_DEPRECATED_PRIVILEGE ", err_type_size);
 
        if (strstr(error_message, "NO_EXIST") != NULL)
-               strncat(err_type, "PRVMGR_ERR_NO_EXIST_PRIVILEGE ", strlen("PRVMGR_ERR_NO_EXIST_PRIVILEGE "));
+               g_strlcat(err_type, "PRVMGR_ERR_NO_EXIST_PRIVILEGE ", err_type_size);
 
        if (strstr(error_message, "MISMATCHED") != NULL)
-               strncat(err_type, "PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL ", strlen("PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL "));
+               g_strlcat(err_type, "PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL ", err_type_size);
 
        if (strstr(error_message, "INVALID_PARAMETER") != NULL)
-               strncat(err_type, "PRVMGR_ERR_INVALID_PARAMETER ", strlen("PRVMGR_ERR_INVALID_PARAMETER "));
+               g_strlcat(err_type, "PRVMGR_ERR_INVALID_PARAMETER ", err_type_size);
 
        if (strstr(error_message, "banned") != NULL)
-               strncat(err_type, "PRVMGR_ERR_USING_BANNED_PRIVILEGE ", strlen("PRVMGR_ERR_USING_BANNED_PRIVILEGE "));
+               g_strlcat(err_type, "PRVMGR_ERR_USING_BANNED_PRIVILEGE ", err_type_size);
 
        if (strlen(err_type) == 0) {
                fail_cnt++;
-               strncat(err_type, "test failed - unknown error type", strlen("test failed - unknown error type "));
+               g_strlcat(err_type, "test failed - unknown error type", err_type_size);
                __color_to_red();
        } else {
                __color_to_blue();