Remove vulnerable codes related to system() function 26/22526/1
authorLi Zhang <li2012.zhang@samsung.com>
Tue, 17 Dec 2013 04:47:50 +0000 (12:47 +0800)
committerLi Zhang <li2012.zhang@samsung.com>
Thu, 5 Jun 2014 09:12:40 +0000 (17:12 +0800)
Change-Id: Iea1c994ff340b042a1e634b9a59f73713ad914e3

wrapper/xim/preferences.c

index 6b83ab7..cc3c412 100644 (file)
@@ -44,6 +44,7 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <sys/types.h>
+#include <stdlib.h>
 
 #include "settings.h"
 #include "xmisc.h"
@@ -313,9 +314,14 @@ static void
 send_reload()
 {
     /* notify all running xsunpinyin with this user */
-    char cmd[256];
-    snprintf(cmd, 256, "/usr/bin/pkill -10 '^xsunpinyin$' -u %d", getuid());
-    system(cmd);
+    pid_t child_pid = fork();
+    if (child_pid == 0)
+    {
+        char cmd[256] = {0};
+        snprintf(cmd, 256, "%d", getuid());
+        execl("/usr/bin/pkill", "/usr/bin/pkill", "-10", "^xsunpinyin$", "-u", cmd, (char*)0);
+        exit(0);
+    }
 }
 
 void