git: 9610cbc09e72 - main - patch: don't run off the end of path if it ends in '/'.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Aug 2023 03:49:51 UTC
The branch main has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=9610cbc09e72c370369b5cc0e165542a2c5fdca7 commit 9610cbc09e72c370369b5cc0e165542a2c5fdca7 Author: Pedro F. Giffuni <pfg@FreeBSD.org> AuthorDate: 2023-08-07 03:27:27 +0000 Commit: Pedro F. Giffuni <pfg@FreeBSD.org> CommitDate: 2023-08-07 03:27:27 +0000 patch: don't run off the end of path if it ends in '/'. Found by fuzzing (afl) in OpenBSD. Obtained from: OpenBSD (CVS 1.65) --- usr.bin/patch/pch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index d1d71f95644c..e180c7075712 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1618,7 +1618,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 */ }