Fixed svace issues 84/205884/1 accepted/tizen/unified/20190512.221850 submit/tizen/20190510.065918
authorsaerome kim <saerome.kim@samsung.com>
Fri, 10 May 2019 05:43:23 +0000 (14:43 +0900)
committersaerome kim <saerome.kim@samsung.com>
Fri, 10 May 2019 05:45:33 +0000 (14:45 +0900)
- 372991: fixed memory leak issue.
- 372995: change a vulnerable function (strerror) to strerror_r.

Change-Id: I2d5e6b815149b30afe0511b831c8d2325abb21b1
Signed-off-by: saerome kim <saerome.kim@samsung.com>
src/mdg_dbus.c [changed mode: 0755->0644]
test/mdg-manager.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index f10dd00..5e439f0
@@ -177,7 +177,9 @@ static void __event_cb(Group *object,
                ret = connect(channel->client_sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
 
                if (ret == -1) {
-                       _DBG("Connect error : %s", strerror(errno));
+                       char buf[128];
+                       strerror_r(errno, buf, 128);
+                       _DBG("Connect error : %s", buf);
                } else {
                        _DBG("Success Connect to %s", ret_ptr);
                }
old mode 100755 (executable)
new mode 100644 (file)
index cec9ac7..35fca8f
@@ -1234,10 +1234,16 @@ void _mdg_channel_client_opened_cb(int result, mdg_channel_h channel, void *user
 
        unsigned char *buf;
        buf = (unsigned char *)malloc(1024);
+       if (NULL == buf) {
+               msgp("memory allocation error");
+               return;
+       }
        int len;
        mdg_channel_read(channel, &buf, &len);
 
        msgp("Get Data : %s, %d", buf, len);
+       free(buf);
+       buf = NULL;
 }
 
 static int __request_open_channel(int devidx, int chaidx)