common: fix a buffer overflow.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Fri, 7 Feb 2014 09:24:17 +0000 (11:24 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 7 Feb 2014 14:14:09 +0000 (16:14 +0200)
src/common/stream-transport.c

index 8ed7bc0..5a5a016 100644 (file)
@@ -172,7 +172,7 @@ static int parse_address(const char *str, int *familyp, char *nodep,
         nl      = strlen(node);
     }
 
-    if (nl > nsize) {
+    if (nl >= nsize) {
         errno = ENOMEM;
         return -1;
     }
@@ -193,7 +193,7 @@ static socklen_t strm_resolve(const char *str, mrp_sockaddr_t *addr,
 {
     struct addrinfo    *ai, hints;
     struct sockaddr_un *un;
-    char                node[512], *port;
+    char                node[UNIX_PATH_MAX], *port;
     socklen_t           len;
 
     mrp_clear(&hints);
@@ -211,7 +211,7 @@ static socklen_t strm_resolve(const char *str, mrp_sockaddr_t *addr,
             errno = ENOMEM;
         else {
             un->sun_family = AF_UNIX;
-            strcpy(un->sun_path, node);
+            strncpy(un->sun_path, node, UNIX_PATH_MAX-1);
             if (un->sun_path[0] == '@')
                 un->sun_path[0] = '\0';
         }