]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Revert "lib/canonicalize: always remove tailing slash"
authorKarel Zak <kzak@redhat.com>
Mon, 26 Mar 2012 08:08:48 +0000 (10:08 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 26 Mar 2012 08:08:48 +0000 (10:08 +0200)
It's overkill to modify unknown paths in a generic function like
canonicalize_path().

for example:

 mount -t fuse 'sshfs#marty@thee:/' /media/thee

will be canonicalized to

 mount -t fuse 'sshfs#marty@thee:' /media/thee

and this obvious bug.

Reported-by: Martin Panter <vadmium+floss@gmail.com>
This reverts commit 28074a0952469aebf021821d95238cfb964d13ff.

lib/canonicalize.c

index fd18af42cee76e58070c8e390300364109510b09..ab32c10431bd88dde3b9b6fff3c88224c28f4811 100644 (file)
@@ -174,16 +174,9 @@ canonicalize_path(const char *path)
        if (path == NULL)
                return NULL;
 
-       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;
-       }
+       if (!myrealpath(path, canonical, PATH_MAX+1))
+               return strdup(path);
+
 
        p = strrchr(canonical, '/');
        if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) {