Add negative number checking logic before ssprintf function. 72/74872/1
authorYunmi Ha <yunmi.ha@samsung.com>
Thu, 16 Jun 2016 02:43:29 +0000 (11:43 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Thu, 16 Jun 2016 02:43:29 +0000 (11:43 +0900)
When converting string to unsigned int,
it can be tainted with negative value.
So before converting, check the negative value.

Change-Id: Ib6cada03a25440599d3d093c4220c64b63782ab0
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
src/common/tlm-config.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 4696344..c49c7f0
@@ -426,7 +426,12 @@ tlm_config_get_uint (
 {
     guint value;
     const gchar *str_value = tlm_config_get_string (self, group, key);
-    if (!str_value || sscanf (str_value, "%u", &value) <= 0) value = retval;
+
+    if (str_value && (*str_value == '-'))  {
+        value = retval;
+    } else  {
+        if (!str_value || sscanf (str_value, "%u", &value) <= 0) value = retval;
+    }
 
     return value;
 }