diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-08-05 13:50:13 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-08-05 13:50:13 +0000 |
commit | b258a6eb13c51f1d0e49441fa4a6337751af0949 (patch) | |
tree | 73f10bdaf125854d14e39bb13b1d2b447f03b1c2 /usr.bin/cvs | |
parent | 5c7e7f55a5b6de77e2219f8a9416588305155812 (diff) |
When splitting a path, strip the trailing slashes before splitting it,
otherwise a path with a trailing slash would give an empty file name
and the original path as the base part
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index adfd8854ba2..6130d9e3916 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.5 2004/07/30 16:52:13 jfb Exp $ */ +/* $OpenBSD: util.c,v 1.6 2004/08/05 13:50:12 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -259,6 +259,10 @@ cvs_splitpath(const char *path, char *dir, size_t dlen, char *file, size_t flen) const char *sp; struct stat st; + rlen = strlen(path); + while ((rlen > 0) && (path[rlen - 1] == '/')) + path[--rlen] = '\0'; + sp = strrchr(path, '/'); if (sp == NULL) { if (stat(path, &st) == -1) |