1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

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)
This commit is contained in:
Pedro F. Giffuni 2023-08-06 22:27:27 -05:00
parent 395b9c9977
commit 9610cbc09e

View File

@ -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 */
}