emuld : fix buffer overflow bug when using sprintf
authorDaiYoung Kim <daiyoung777.kim@samsung.com>
Thu, 25 Apr 2013 09:24:37 +0000 (18:24 +0900)
committerDaiYoung Kim <daiyoung777.kim@samsung.com>
Thu, 25 Apr 2013 09:24:37 +0000 (18:24 +0900)
Signed-off-by: DaiYoung, Kim <daiyoung777.kim@samsung.com>
packaging/emuld.spec
src/emuld.c

index a89fcc80a89d34a9198235936b031d50a8935a1d..e666bc4d7b72fb498f60cdb4c8742a214cab3538 100755 (executable)
@@ -1,6 +1,6 @@
 #git:/slp/pkgs/e/emulator-daemon
 Name: emuld
-Version: 0.2.35
+Version: 0.2.36
 Release: 1
 Summary: emuld is used for communication emulator between and ide.
 License: Apache
index 239dce2684f2fed196cd87c775286826b2093635..77f8fa979d627f00fb43908bbcd6cc6ceea4dcae 100755 (executable)
@@ -1298,7 +1298,13 @@ void setting_location(char* databuf)
 //sdcard event
 void send_guest_server(char* databuf)
 {
-       char buf[32];
+       if (!databuf)
+       {
+               LOG("invalid data buf");
+               return;
+       }
+
+       char buf[64];
        struct sockaddr_in si_other;
        int s, slen=sizeof(si_other);
        FILE* fd;
@@ -1332,7 +1338,8 @@ void send_guest_server(char* databuf)
        }
 
        memset(buf, '\0', sizeof(buf));
-       sprintf(buf, "4\n%s", databuf);
+       snprintf(buf, 60, "4\n%s", databuf);
+
        LOG("sendGuestServer msg: %s", buf);
        if(sendto(s, buf, sizeof(buf), 0, (struct sockaddr*)&si_other, slen) == -1)
        {