From f344f57b431a3f713873cd19bf346f494ac561db Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 12 Jul 2023 15:45:34 +0000 Subject: [PATCH] Don't run off the end of path if it ends in /. OK op, sthen --- usr.bin/patch/pch.c | 5 +++-- 1 file 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 */ } -- 2.20.1