Pino Toscano
2014-Oct-13 14:49 UTC
[Libguestfs] [PATCH] cat, diff: avoid double slashes in paths (RHBZ#1151910).
In full_path, skip the trailing slash in the base directory when different than "/", as the slash will eventually be added when building the resulting path. --- cat/visit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cat/visit.c b/cat/visit.c index 963beb8..49b779e 100644 --- a/cat/visit.c +++ b/cat/visit.c @@ -138,13 +138,18 @@ full_path (const char *dir, const char *name) { int r; char *path; + int len; + + len = strlen (dir); + if (len > 0 && dir[len - 1] == '/') + --len; if (STREQ (dir, "/")) r = asprintf (&path, "/%s", name ? name : ""); else if (name) - r = asprintf (&path, "%s/%s", dir, name); + r = asprintf (&path, "%.*s/%s", len, dir, name); else - r = asprintf (&path, "%s", dir); + r = asprintf (&path, "%.*s", len, dir); if (r == -1) { perror ("asprintf"); -- 1.9.3
Apparently Analagous Threads
- [PATCH] daemon: Translate device names if Linux device ordering is unstable (RHBZ#1804207).
- [PATCH] ls: in CSV mode, always have a checksum field (RHBZ#1151900).
- [PATCH] virt-diff: add additional ignore options
- [PATCH 2/2] Use setfiles from the appliance for the SELinux relabel (RHBZ#1089100).
- [PATCH] virt-diff: add additional ignore options