diff options
Diffstat (limited to 'lib/canonicalize.c')
-rw-r--r-- | lib/canonicalize.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/canonicalize.c b/lib/canonicalize.c index ab32c1043..fd18af42c 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -174,9 +174,16 @@ canonicalize_path(const char *path) if (path == NULL) return NULL; - if (!myrealpath(path, canonical, PATH_MAX+1)) - return strdup(path); - + if (!myrealpath(path, canonical, PATH_MAX+1)) { + char *res = strdup(path); + if (res) { + p = strrchr(res, '/'); + /* delete trailing slash */ + if (p && p > res && *(p + 1) == '\0') + *p = '\0'; + } + return res; + } p = strrchr(canonical, '/'); if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) { |