summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/util.c
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:50:13 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:50:13 +0000
commitb258a6eb13c51f1d0e49441fa4a6337751af0949 (patch)
tree73f10bdaf125854d14e39bb13b1d2b447f03b1c2 /usr.bin/cvs/util.c
parent5c7e7f55a5b6de77e2219f8a9416588305155812 (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/util.c')
-rw-r--r--usr.bin/cvs/util.c6
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)