Fix critical svace issue 68/253368/1 tizen_6.0
authorMukunth A <a.mukunth@samsung.com>
Tue, 9 Feb 2021 07:16:06 +0000 (12:46 +0530)
committerMukunth A <a.mukunth@samsung.com>
Tue, 9 Feb 2021 07:42:11 +0000 (07:42 +0000)
Change-Id: Ifada7275c36ff6ca59ed51d068a257398ba69a84
Signed-off-by: Mukunth A <a.mukunth@samsung.com>
(cherry picked from commit 0aafac733af16cd8c70b8c14d0559303f669b73d)

CMain/src/orchestration_dbus_server.c

index b5b06d3..adb85f4 100644 (file)
@@ -262,10 +262,10 @@ static void _handle_method_call(
             {
                 // find count of IP addr
                 ipaddr_listcopy = strdup(ipaddr_list);
-                char *token = strtok(ipaddr_listcopy, ",");
-                while (token != NULL)
+                char *str = ipaddr_listcopy;
+                char *token = NULL;
+                while ((token = strtok_r(str, ",", &str)))
                 {
-                    token = strtok(NULL, ",");
                     count++;
                 }
 
@@ -273,8 +273,9 @@ static void _handle_method_call(
                 {
                     // Parse IP address
                     ipaddr = (char**) malloc(sizeof(char *) * count);
-                    token = strtok(ipaddr_list, ",");
-                    while (token != NULL)
+                    str = ipaddr_list;
+                    token = NULL;
+                    while ((token = strtok_r(str, ",", &str)))
                     {
                         char *addr = (char*) malloc(sizeof(char) * (strlen(token) + 1));
                         if (addr)
@@ -284,7 +285,6 @@ static void _handle_method_call(
                             ipaddr[num_ip] = addr;
                             num_ip++;
                         }
-                        token = strtok(NULL, ",");
                     }
                 }
                 free(ipaddr_listcopy);