From f0cf8a50669beb4dd1159b8dce0f448453fb0c9d Mon Sep 17 00:00:00 2001 From: Jaeyun Date: Tue, 30 Apr 2019 16:31:49 +0900 Subject: [PATCH] [Filter/TF] use glib to parse and compare string use glib to compare and parse strings (fix one of security issues) Signed-off-by: Jaeyun Jung --- ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc | 8 ++++---- ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc index f85438f..6fb1f11 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc @@ -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; diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h index 24591e1..0d9730a 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h @@ -28,9 +28,6 @@ #include #include -#include -#include -#include #include "nnstreamer_plugin_api_filter.h" -- 2.7.4