]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount: avoid unguarded strcpy
authorSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 20:56:38 +0000 (13:56 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 20:56:38 +0000 (13:56 -0700)
Use strdup here, mostly to make coverity shut up.

Coverity cid 45

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

index 34fce4def906371abdaa2fa0abb77a69d8c3dc50..9dafd0d6f33d2455d6709cfeace1229d363581a7 100755 (executable)
@@ -39,15 +39,16 @@ static char *mount_resolve_src(const char *orig_str)
        int len, pos;
        char *mount_path;
        char *src;
-       char buf[strlen(orig_str) + 1];
-       strcpy(buf, orig_str);
+       char *buf = strdup(orig_str);
        mount_path = strrchr(buf, ':');
        if (!mount_path) {
                printf("source mount path was not specified\n");
+               free(buf);
                return NULL;
        }
        if (mount_path == buf) {
                printf("server address expected\n");
+               free(buf);
                return NULL;
        }
 
@@ -56,10 +57,12 @@ static char *mount_resolve_src(const char *orig_str)
 
        if (!*mount_path) {
                printf("incorrect source mount path\n");
+               free(buf);
                return NULL;
        }
 
        src = resolve_addrs(buf);
+       free(buf);
        if (!src)
                return NULL;