misc: Arrange source codes
authorMunkyu Im <munkyu.im@samsung.com>
Tue, 16 Dec 2014 08:40:40 +0000 (17:40 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Tue, 16 Dec 2014 08:40:40 +0000 (17:40 +0900)
Fix delete non-array
Change strcpy() to strncpy()
Fix null pointer dereference

Change-Id: I4ab90cc9e144155a0658320dde69e9533c1d525a
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
packaging/emuld.spec
src/common_dev.cpp

index b1b0e559ebc31cd050e9db378c3518250b4e2697..f3ee96361ae68bd914ccf79215f1a4b6aa2b1800 100644 (file)
@@ -1,5 +1,5 @@
 Name: emuld
-Version: 0.8.2
+Version: 0.8.3
 Release: 0
 Summary: Emulator daemon
 License: Apache-2.0
index e9ecbf37452cf464e5e7e45fc2bfc84f31ef9334..979f247170687af79327bdda4189f15043a0d6ae 100644 (file)
@@ -298,7 +298,7 @@ void msgproc_sdcard(const int sockfd, ijcommand* ijcmd)
             {
                 memset(SDpath, '\0', sizeof(SDpath));
                 ret = strtok(NULL, token);
-                strcpy(SDpath, ret);
+                strncpy(SDpath, ret, strlen(ret));
                 LOGDEBUG("sdcard path is %s", SDpath);
 
                 mount_param* param = new mount_param(sockfd);
@@ -378,13 +378,16 @@ void msgproc_sdcard(const int sockfd, ijcommand* ijcmd)
                                     memcpy(tmp + HEADER_SIZE + mntData->length, mountinfo, mountinfo_size);
                                     mntData->length += mountinfo_size;
                                     memcpy(tmp, mntData, HEADER_SIZE);
-                                    delete mountinfo;
-                                    mountinfo = NULL;
+                                    free(mountinfo);
                                 }
 
                                 ijmsg_send_to_evdi(g_fd[fdtype_device], IJTYPE_SDCARD, (const char*) tmp, tmplen);
 
                                 free(tmp);
+                            } else {
+                                if (mountinfo) {
+                                    free(mountinfo);
+                                }
                             }
                         }
                         break;
@@ -506,13 +509,16 @@ static char* get_location_status(void* p)
         }
     }
 
-    LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
-    memset(packet, 0, sizeof(LXT_MESSAGE));
-    packet->length = strlen(message);
-    packet->group  = STATUS;
-    packet->action = LOCATION_STATUS;
-
-    return message;
+    if (message) {
+        LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+        memset(packet, 0, sizeof(LXT_MESSAGE));
+        packet->length = strlen(message);
+        packet->group  = STATUS;
+        packet->action = LOCATION_STATUS;
+        return message;
+    } else {
+        return NULL;
+    }
 }
 
 static void* getting_location(void* data)
@@ -571,12 +577,9 @@ static void* getting_location(void* data)
         free(msg);
         msg = 0;
     }
-    if (packet)
-    {
+    if (packet != NULL) {
         free(packet);
-        packet = NULL;
     }
-
     if (param)
         delete param;