From: florian Date: Wed, 12 Jul 2023 15:45:34 +0000 (+0000) Subject: Don't run off the end of path if it ends in /. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f344f57b431a3f713873cd19bf346f494ac561db;p=openbsd Don't run off the end of path if it ends in /. OK op, sthen --- 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 */ }