From 5450e56ba4644f335151db090e773c37aa4800bc Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 17 Apr 2005 19:46:50 +0000 Subject: [PATCH] A very minor tweak to the handling of leading '/' characters. --- usr.bin/tar/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/tar/util.c b/usr.bin/tar/util.c index 7f1a9442ee23..69cc67117c5b 100644 --- a/usr.bin/tar/util.c +++ b/usr.bin/tar/util.c @@ -412,6 +412,10 @@ edit_pathname(struct bsdtar *bsdtar, struct archive_entry *entry) if (name[0] == '.' && name[1] == '/' && name[2] != '\0') name += 2; + /* Strip redundant leading '/' characters. */ + while (name[0] == '/' && name[1] == '/') + name++; + /* Strip leading '/' unless user has asked us not to. */ if (name[0] == '/' && !bsdtar->option_absolute_paths) { /* Generate a warning the first time this happens. */ @@ -421,7 +425,8 @@ edit_pathname(struct bsdtar *bsdtar, struct archive_entry *entry) bsdtar->warned_lead_slash = 1; } name++; - if (*name == '\0') /* Strip '/' from "/" yields "." */ + /* Special case: Stripping leading '/' from "/" yields ".". */ + if (*name == '\0') name = "."; }