[Pkg-libvirt-commits] [libguestfs] 08/61: cat, diff: avoid double slashes in paths (RHBZ#1151910).

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 31 19:09:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.28.2-1
in repository libguestfs.

commit fb9de262f41bd4dbfe1668b2c07c0aaebc4ff0fa
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Mon Oct 13 16:49:59 2014 +0200

    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.
    
    (cherry picked from commit 87941d183f4a96b4d936c2e94a79a60288f0dc74)
---
 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");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list