summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAleksander Piotrowski <alek@cvs.openbsd.org>2005-12-21 19:59:59 +0000
committerAleksander Piotrowski <alek@cvs.openbsd.org>2005-12-21 19:59:59 +0000
commit5de634cd849e8233913ae500eae4dd3050b81a40 (patch)
tree6cbe2fd68e96abc789c1282c6680a7605f851d22 /usr.bin
parent5fe4d1465d5db4510bf37596322908b8491208b1 (diff)
Initialize basepath right after xmalloc()ing it so we won't end up with
not NUL-terminated buffer passed to strlcat() ok joris@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/ci.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index ffd189059d5..fd9b9eaa3da 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.87 2005/12/20 09:04:17 xsa Exp $ */
+/* $OpenBSD: ci.c,v 1.88 2005/12/21 19:59:58 alek Exp $ */
/*
* Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -754,6 +754,7 @@ checkin_choose_rcsfile(const char *filename)
struct stat sb;
basepath = xmalloc(MAXPATHLEN);
+ basepath[0] = '\0';
if (strchr(filename, '/') == NULL) {
strlcat(basepath, RCSDIR"/", MAXPATHLEN);
if ((stat(basepath, &sb) == 0) && (sb.st_mode & S_IFDIR)) {
@@ -762,7 +763,6 @@ checkin_choose_rcsfile(const char *filename)
strlcat(basepath, RCS_FILE_EXT, MAXPATHLEN);
} else {
/* <path>/<filename>,v */
- memset(basepath, '\0', MAXPATHLEN);
strlcpy(basepath, filename, MAXPATHLEN);
strlcat(basepath, RCS_FILE_EXT, MAXPATHLEN);
}
@@ -793,7 +793,6 @@ checkin_choose_rcsfile(const char *filename)
strlcat(basepath, RCS_FILE_EXT, MAXPATHLEN);
} else {
/* <path>/<filename>,v */
- memset(basepath, '\0', MAXPATHLEN);
strlcpy(basepath, filename, MAXPATHLEN);
strlcat(basepath, RCS_FILE_EXT, MAXPATHLEN);
}