Change strtok into strtok_r for thread safety 40/87640/1
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 9 Sep 2016 03:54:50 +0000 (12:54 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Fri, 9 Sep 2016 03:54:50 +0000 (12:54 +0900)
[Version] 0.1.7 (same as version wriiten in spec file)
[Profile] Common
[Issue Type] Fix bugs

Change-Id: Ib2bb256a15bbd92428e8f7b81ecc96dbb3fbd091
Signed-off-by: Gilbok Lee <gilbok.lee@samsung.com>
src/muse_core_log.c

index c48a8ac..e1d352f 100644 (file)
@@ -146,14 +146,15 @@ static void _muse_core_log_binary_info(void)
        FILE *fp;
        char *label;
        char *value;
+       char *ptr = NULL;
 
        snprintf(client_buf, sizeof(client_buf), "/etc/tizen-release");
 
        fp = fopen(client_buf, "r");
        if (fp) {
                while (fgets(client_buf, MAX_ERROR_MSG_LEN, fp)) {
-                       label = strtok(client_buf, delimiter);
-                       value = strtok(NULL, delimiter);
+                       label = strtok_r(client_buf, delimiter, &ptr);
+                       value = strtok_r(NULL, delimiter, &ptr);
                        if (strcmp(label, BUILD_ID) == 0) {
                                if (write(g_muse_core_log->log_fd, value, strlen(value)) != WRITE_FAIL)
                                        LOGE("[%s] %s", BUILD_ID, value);