From 306a127cab5ecfafa994e6cf676e16e101f2ad60 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 4 Feb 2012 10:03:29 -0700 Subject: [PATCH] canonicalize-lgpl: fix // handling Same as the previous patch, for the lgpl version. * lib/canonicalize-lgpl.c (__realpath): Don't convert /// to //. Signed-off-by: Eric Blake --- ChangeLog | 3 +++ lib/canonicalize-lgpl.c | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9aa40a9a..cbd86372d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-02-04 Eric Blake + canonicalize-lgpl: fix // handling + * lib/canonicalize-lgpl.c (__realpath): Don't convert /// to //. + canonicalize: fix // handling * lib/canonicalize.c (canonicalize_filename_mode): Don't convert /// to //, since only // is special. diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 2fd79dcd9..a61bef90e 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -156,7 +156,7 @@ __realpath (const char *name, char *resolved) { rpath[0] = '/'; dest = rpath + 1; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != '/') *dest++ = '/'; } @@ -187,7 +187,7 @@ __realpath (const char *name, char *resolved) if (dest > rpath + 1) while ((--dest)[-1] != '/'); if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 - && *dest == '/') + && *dest == '/' && dest[1] != '/') dest++; } else @@ -298,7 +298,8 @@ __realpath (const char *name, char *resolved) if (buf[0] == '/') { dest = rpath + 1; /* It's an absolute symlink */ - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT + && buf[1] == '/' && buf[2] != '/') *dest++ = '/'; } else @@ -308,7 +309,7 @@ __realpath (const char *name, char *resolved) if (dest > rpath + 1) while ((--dest)[-1] != '/'); if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 - && *dest == '/') + && *dest == '/' && dest[1] != '/') dest++; } } @@ -321,7 +322,8 @@ __realpath (const char *name, char *resolved) } if (dest > rpath + 1 && dest[-1] == '/') --dest; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 && *dest == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 + && *dest == '/' && dest[1] != '/') dest++; *dest = '\0'; -- 2.11.0