summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2023-07-12 15:45:35 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2023-07-12 15:45:35 +0000
commit23541d4ff17dd58157aa7b86692d8029d6038e4c (patch)
tree1d0131197ac830fdb94ac78a41cc091fc26b4321 /usr.bin/patch
parentc07ceac97a1cfcd7446d82b7a9149c2520aab04f (diff)
Don't run off the end of path if it ends in /.
OK op, sthen
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/pch.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index a3e0a9cf5f8..7c65062a719 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.65 2023/07/12 15:44:47 florian Exp $ */
+/* $OpenBSD: pch.c,v 1.66 2023/07/12 15:45:34 florian Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -1484,7 +1484,8 @@ num_components(const char *path)
size_t n;
const char *cp;
- for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++, cp++) {
+ for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++) {
+ cp++;
while (*cp == '/')
cp++; /* skip consecutive slashes */
}