fix a issue reported by prevent.
authorKyuho Jo <kyuho.jo@samsung.com>
Thu, 15 Jan 2015 04:37:42 +0000 (13:37 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Thu, 15 Jan 2015 04:37:42 +0000 (13:37 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] 348160
[problem] Prevent issue type 'Copy into fixed size buffer'
[cause]
[solution] Copy string by using strncpy
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: I6a9b9b985fd514e3f6ed03f63ddf1dafeacfeb93
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
util_liveinfo/src/liveinfo.c

index 7b683e3..4b4291d 100644 (file)
@@ -1380,10 +1380,12 @@ static void do_command(const char *cmd)
     return;
 }
 
+#define CMD_BUFFER_SIZE 256
+
 static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler)
 {
     static int idx = 0;
-    static char cmd_buffer[256];
+    static char cmd_buffer[CMD_BUFFER_SIZE];
     unsigned char ch;
     int fd;
     int ret;
@@ -1438,7 +1440,8 @@ static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler)
                        cmd_buffer[0] = '\0';
                        prompt(NULL);
                    } else {
-                       strcpy(cmd_buffer, tmp);
+                       strncpy(cmd_buffer, tmp, CMD_BUFFER_SIZE - 1);
+                       cmd_buffer[CMD_BUFFER_SIZE - 1]  = '\0';
                        idx = strlen(cmd_buffer);
                        prompt(cmd_buffer);
                    }