]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount: avoid big stack item
authorSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 20:49:10 +0000 (13:49 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 20:49:10 +0000 (13:49 -0700)
Coverity cid 55

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

index 4ea5170e99053622a50d64b840813f3dc3289a1d..8ff602e807e309faafb24298b061e0c35d5c148a 100644 (file)
@@ -168,24 +168,29 @@ canonicalize_dm_name(const char *ptname)
 char *
 canonicalize_path(const char *path)
 {
-       char canonical[PATH_MAX+2];
+       char *canonical;
        char *p;
 
        if (path == NULL)
                return NULL;
 
-       if (!myrealpath(path, canonical, PATH_MAX+1))
+       canonical = malloc(PATH_MAX+2);
+       if (!myrealpath(path, canonical, PATH_MAX+1)) {
+               free(canonical);
                return strdup(path);
+       }
 
 
        p = strrchr(canonical, '/');
        if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) {
                p = canonicalize_dm_name(p+1);
-               if (p)
+               if (p) {
+                       free(canonical);
                        return p;
+               }
        }
 
-       return strdup(canonical);
+       return canonical;
 }