[Subplugin] check symlink before getting handle
authorJaeyun <jy1210.jung@samsung.com>
Tue, 30 Apr 2019 08:19:41 +0000 (17:19 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 8 May 2019 08:14:02 +0000 (17:14 +0900)
Add code to check symlink before open file handle.
(fix one of security issues)

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/nnstreamer/nnstreamer_subplugin.c
gst/nnstreamer/tensor_filter/tensor_filter_custom.c

index 04c09ee..2a4c3d9 100644 (file)
@@ -74,7 +74,10 @@ get_subplugin (subpluginType type, const char *name)
     /* Search and register if found with the conf */
     const gchar *fullpath = nnsconf_get_fullpath (name, type);
 
-    if (fullpath == NULL)
+    /**
+     * @todo Consider to add option to open symbolic link file and version-specified library name.
+     */
+    if (fullpath == NULL || g_file_test (fullpath, G_FILE_TEST_IS_SYMLINK))
       goto error;               /* No Such Thing !!! */
 
     G_UNLOCK (splock);
index 7f94bee..9a8f47d 100644 (file)
@@ -70,6 +70,14 @@ custom_loadlib (const GstTensorFilterProperties * prop, void **private_data)
     return -1;
   }
 
+  /**
+   * @todo Consider to add option to open symbolic link file and version-specified library name.
+   */
+  if (g_file_test (prop->model_file, G_FILE_TEST_IS_SYMLINK)) {
+    /* symbolic link */
+    return -1;
+  }
+
   ptr = g_new0 (internal_data, 1);      /* Fill Zero! */
   *private_data = ptr;