On 2023/07/12 12:54:54 +0200, Florian Obser <flor...@openbsd.org> wrote:
> Found with afl, if path ends in '/', num_components will run off the end
> of the string.
> 
> OK?

ok op

> (this is on top of tb's fix on bugs but should be independent and not
> cause conflicts.)
> 
> diff --git pch.c pch.c
> index 63543a609fb..8c58dc9ffe5 100644
> --- pch.c
> +++ pch.c
> @@ -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 */
>       }


Reply via email to