]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
addr_parsing: avoid strcpy
authorSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 21:03:00 +0000 (14:03 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 21:03:00 +0000 (14:03 -0700)
Make coverity shut up.

Coverity cid 44

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/addr_parsing.c
src/mount/mount.ceph.c

index c844b3caa2744454183248e83208bace74442f74..465a47064513e738be485abe687d3e41d6c21af8 100644 (file)
@@ -44,8 +44,7 @@ char *resolve_addrs(const char *orig_str)
   char *new_str;
   char *tok, *p, *port_str, *saveptr;
   int len, pos;
-  char buf[strlen(orig_str) + 1];
-  strcpy(buf, orig_str);
+  char *buf = strdup(orig_str);
 
   len = BUF_SIZE;
   new_str = (char *)malloc(len);
@@ -97,6 +96,7 @@ char *resolve_addrs(const char *orig_str)
     if (r < 0) {
       printf("server name not found: %s (%s)\n", tok, strerror(errno));
       free(new_str);
+      free(buf);
       return 0;
     }
 
@@ -136,5 +136,6 @@ char *resolve_addrs(const char *orig_str)
   }
 
   //printf("new_str is '%s'\n", new_str);
+  free(buf);
   return new_str;
 }
index 9dafd0d6f33d2455d6709cfeace1229d363581a7..010337f860f5716a176b38076507ad52c1c7cf58 100755 (executable)
@@ -40,6 +40,7 @@ static char *mount_resolve_src(const char *orig_str)
        char *mount_path;
        char *src;
        char *buf = strdup(orig_str);
+
        mount_path = strrchr(buf, ':');
        if (!mount_path) {
                printf("source mount path was not specified\n");