diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-28 19:05:27 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-28 19:05:27 +0000 |
commit | 8cbceee28755586acde5bcbd73e719d87b265df4 (patch) | |
tree | 6d3e8acfc02e355cf5f1db1f5fbcda1dee11e1b2 /usr.bin | |
parent | ddc51679e0d7a0d497bf7cd7e9d2866c5be2aa5d (diff) |
Don't treat consecutive slashes as path components; matches POSIX
OK otto@ and deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/patch/util.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 819e2cb24d6..32d25e451cf 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,7 +1,7 @@ -/* $OpenBSD: util.c,v 1.20 2003/07/28 18:35:36 otto Exp $ */ +/* $OpenBSD: util.c,v 1.21 2003/07/28 19:05:26 millert Exp $ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: util.c,v 1.20 2003/07/28 18:35:36 otto Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.21 2003/07/28 19:05:26 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -322,7 +322,6 @@ char * fetchname(const char *at, int strip_leading, int assume_exists) { char *fullname, *name, *t, tmpbuf[200]; - int sleading = strip_leading; struct stat filestat; if (at == NULL || *at == '\0') @@ -337,11 +336,12 @@ fetchname(const char *at, int strip_leading, int assume_exists) return NULL; /* against /dev/null. */ name = fullname = t = savestr(at); - /* Strip off up to `sleading' leading slashes and null terminate. */ - for (; *t && !isspace(*t); t++) - if (*t == '/') - if (--sleading >= 0) + /* Strip off up to `strip_leading' path components and NUL terminate. */ + for (; *t != '\0' && !isspace(*t); t++) { + if (t[0] == '/' && t[1] != '/' && t[1] != '\0') + if (--strip_leading >= 0) name = t + 1; + } *t = '\0'; /* |