Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Aug 2023 03:49:51 GMT
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 9610cbc09e72 - main - patch: don't run off the end of path if it ends in '/'.
Message-ID:  <202308070349.3773nppG062057@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308070349.3773nppG062057>