fix prevent potentional bugs 42/11242/1
authorho.namkoong <ho.namkoong@samsung.com>
Wed, 23 Oct 2013 06:47:11 +0000 (15:47 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Wed, 23 Oct 2013 06:47:11 +0000 (15:47 +0900)
Change-Id: Ic7f5901da5abf9a57608aba7ba4b474e8567f168

src/file_sync_functions.c
src/sockets.c
src/transport.c

index d4013e665ef44342cd6708879c20d3eec6e5febb..ad833b3b98bbb4a205d43782190210b29cf73305 100644 (file)
@@ -289,7 +289,7 @@ int writeclose_remote(int fd, char* dstp, struct stat* st) {
         char buf[256];
         if(msg.status.id == sync_fail) {
             int len = ltohl(msg.status.msglen);
-            if(len > 256) {
+            if(len > 255) {
                 len = 255;
             }
             if(readx(fd, buf, len)) {
index 04e4076f75c39cef528e3975480b3076a6252be4..6df0eb7a113a5e8f139c74f4d016c67e18ecce8c 100755 (executable)
@@ -859,6 +859,10 @@ connect_done:
         strncpy(host_buf, _host, sizeof(host_buf) - 1);
         _host = host_buf;
         char* serial = strchr(host_buf, ':');
+
+        if(serial == NULL) {
+            sendfailmsg(socket->fd, "serial number is NULL. cannot find the target device\n");
+        }
         *(serial) = '\0';
         serial++;
 
index 69a4f7f25f038d916744a5017b186f2901ec8dfd..173571cb674ee1fb30a3a8658f587ec07d5c9ff9 100755 (executable)
@@ -283,9 +283,7 @@ static void parse_banner(char *data, TRANSPORT *t)
     else {
         t->connection_state = CS_HOST;
     }
-    if (banner != NULL) {
-        s_free(banner);
-    }
+    s_free(banner);
     // since version 2
     char *tokens[CNXN_DATA_MAX_TOKENS];
     size_t cnt = tokenize(data, "::", tokens, CNXN_DATA_MAX_TOKENS);