[Filter/TF] use glib to parse and compare string
authorJaeyun <jy1210.jung@samsung.com>
Tue, 30 Apr 2019 07:31:49 +0000 (16:31 +0900)
committerwooksong <wook16.song@samsung.com>
Fri, 3 May 2019 14:08:01 +0000 (23:08 +0900)
use glib to compare and parse strings (fix one of security issues)

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h

index f85438f..6fb1f11 100644 (file)
@@ -298,7 +298,7 @@ TFCore::validateInputTensor (const GraphDef &graph_def)
       dtype = node->attr ().at ("dtype").type ();
     }
 
-    if (!tensor_name || strcmp (tensor_name, node->name ().c_str ())) {
+    if (!tensor_name || !g_str_equal (tensor_name, node->name ().c_str ())) {
       GST_ERROR ("Input Tensor is not valid: the name of input tensor is different\n");
       return -2;
     }
@@ -314,7 +314,7 @@ TFCore::validateInputTensor (const GraphDef &graph_def)
     }
 
     gchar **str_dims;
-    unsigned int rank, dim;
+    guint rank, dim;
     TensorShape ts = TensorShape ({});
 
     str_dims = g_strsplit (shape_description.c_str (), ",", -1);
@@ -330,10 +330,10 @@ TFCore::validateInputTensor (const GraphDef &graph_def)
       dim = inputTensorMeta.info[i].dimension[rank - j - 1];
       ts.AddDim (dim);
 
-      if (!strcmp (str_dims[j], "?"))
+      if (g_str_equal (str_dims[j], "?"))
         continue;
 
-      if (dim != atoi (str_dims[j])) {
+      if (dim != (guint) g_ascii_strtoull (str_dims[j], NULL, 10)) {
         GST_ERROR ("Input Tensor is not valid: the dim of input tensor is different\n");
         g_strfreev (str_dims);
         return -4;
index 24591e1..0d9730a 100644 (file)
@@ -28,9 +28,6 @@
 
 #include <glib.h>
 #include <gst/gst.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <string.h>
 
 #include "nnstreamer_plugin_api_filter.h"