Fix strtok_r bug 35/151535/1 accepted/tizen/4.0/unified/20170921.160604 submit/tizen_4.0/20170921.084313
authorSunmin Lee <sunm.lee@samsung.com>
Thu, 21 Sep 2017 06:13:45 +0000 (15:13 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Thu, 21 Sep 2017 06:21:08 +0000 (15:21 +0900)
In previous code the strtok and strtok_r were mixed
in order to preserve each context.
When fixed svace issues, this intention was not considered.
Fix the bug about it.

Change-Id: I76d838370fa5d3d0ebcf16b0e33e3055f5b869f8
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
ss_engine/SS_UPI.c

index b974c18..be6bbcd 100755 (executable)
@@ -1158,7 +1158,8 @@ int SS_FSSetAttributes(ua_dataSS_t * ua_dataSS)
     }
 
     while (pline) {
-        pfilePath = strtok_r(pline, "\"", &psaveptr);
+        char *saveptr_pline;
+        pfilePath = strtok_r(pline, "\"", &saveptr_pline);
 
         if (pfilePath && strcmp(pfilePath, SS_FWSLASH) == 0) {
             LOGE("\n skip root: it is RO");
@@ -1166,9 +1167,9 @@ int SS_FSSetAttributes(ua_dataSS_t * ua_dataSS)
             continue;
         }
 
-        pfiletype = strtok_r(NULL, SS_TOKEN_SPACE, &psaveptr);
-        attributSize = strtok_r(NULL, SS_TOKEN_SPACE, &psaveptr);
-        pattribs = strtok_r(NULL, SS_TOKEN_NEWLINE, &psaveptr);
+        pfiletype = strtok_r(NULL, SS_TOKEN_SPACE, &saveptr_pline);
+        attributSize = strtok_r(NULL, SS_TOKEN_SPACE, &saveptr_pline);
+        pattribs = strtok_r(NULL, SS_TOKEN_NEWLINE, &saveptr_pline);
         LOG("\nSS_FSSetAttributes [%s][%s][%s]", pfiletype, attributSize, pattribs);
         if (pattribs && pfilePath && pfiletype) {
             ulAttribSize = strlen(pattribs);