[Tizen] Fix SVACE issue - change sscanf(%d) to strtol 30/127830/1 accepted/tizen/unified/20170502.165632 submit/tizen/20170502.061218
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 2 May 2017 02:08:03 +0000 (11:08 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 2 May 2017 02:08:09 +0000 (11:08 +0900)
This reverts commit 644efdd504e3acf1807075cb61c247189d130503.

Change-Id: I8ad145366db6984d6b8ff9f5462b903eda3580ad

dali-toolkit/third-party/nanosvg/nanosvg.cc

index d3ffc40..601413c 100644 (file)
@@ -1038,9 +1038,15 @@ static unsigned int nsvg__parseColorRGB(const char* str)
 
     /**
      * In the original file, the formatted data reading did not specify the string with width limitation.
-     * To prevent the possible overflow, we replace '%s' with '%32s' here.
+     * To prevent the possible overflow, we replace '%s' with '%31s' and use strtol here
      */
-    sscanf(str + 4, "%d%32[%%, \t]%d%32[%%, \t]%d", &r, s1, &g, s2, &b);
+    char* end;
+    r = strtol(str + 4, &end, 10);
+    sscanf(end, "%31[%%, \t]", s1);
+    g = strtol(end + strlen(s1), &end, 10);
+    sscanf(end, "%31[%%, \t]", s2);
+    b = strtol(end + strlen(s2), &end, 10);
+
     if (strchr(s1, '%')) {
         return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
     } else {
@@ -1269,9 +1275,9 @@ static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
 
     /**
      * In the original file, the formatted data reading did not specify the string with width limitation.
-     * To prevent the possible overflow, we replace '%s' with '%32s' here.
+     * To prevent the possible overflow, we replace '%s' with '%31s' here.
      */
-    sscanf(str, "%f%32s", &coord.value, units);
+    sscanf(str, "%f%31s", &coord.value, units);
     coord.units = nsvg__parseUnits(units);
     return coord;
 }