summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@cvs.openbsd.org>2016-01-19 14:51:01 +0000
committerSunil Nimmagadda <sunil@cvs.openbsd.org>2016-01-19 14:51:01 +0000
commitbd64d79564a467bde98ea6b968edea6d56ae95b7 (patch)
tree32f46d2f339e0d819bcec3a11581742aaeb2232e /usr.bin
parent5a7ff55cd1b3672c5fde9ca5cdfe45ebb93675fd (diff)
Bounds check while stripping trailing slashes. From max at
max-fillinger.net. Ok lum@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/cscope.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/mg/cscope.c b/usr.bin/mg/cscope.c
index 02fca962aa1..d84ec7faa1f 100644
--- a/usr.bin/mg/cscope.c
+++ b/usr.bin/mg/cscope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cscope.c,v 1.15 2016/01/19 11:39:06 sunil Exp $ */
+/* $OpenBSD: cscope.c,v 1.16 2016/01/19 14:51:00 sunil Exp $ */
/*
* This file is in the public domain.
@@ -614,7 +614,7 @@ csexists(const char *cmd)
continue;
dlen = strlen(dir);
- while (dir[dlen-1] == '/')
+ while (dlen > 0 && dir[dlen-1] == '/')
dir[--dlen] = '\0'; /* strip trailing '/' */
len = snprintf(fname, sizeof(fname), "%s/%s", dir, cmd);