Re: authpf: fix dead whitespace-trim loop in read_config

Alexandr Nedvedicky <[email protected]> Sun, 19 Jul 2026 13:13:22 +0200
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
Hello,

thank you for you debugging the issue and sharing the fix.
I will commit your diff tomorrow unless there will be
objection.


On Fri, Jul 17, 2026 at 04:29:50PM +0530, Avinash Duduskar wrote:
</snip<
> 
> diff --git a/usr.sbin/authpf/authpf.c b/usr.sbin/authpf/authpf.c
> index bc410c0631c..3984e4d78d2 100644
> --- a/usr.sbin/authpf/authpf.c
> +++ b/usr.sbin/authpf/authpf.c
> @@ -396,8 +396,8 @@ read_config(FILE *f)
>  		if (ap != &pair[2])
>  			goto parse_error;
>  
> -		tp = pair[1] + strlen(pair[1]);
> -		while ((*tp == ' ' || *tp == '\t') && tp >= pair[1])
> +		tp = pair[1] + strlen(pair[1]) - 1;
> +		while (tp >= pair[1] && (*tp == ' ' || *tp == '\t'))
>  			*tp-- = '\0';
>  
>  		if (strcasecmp(pair[0], "anchor") == 0) {
> 

    I've tested the change above using invalid input as follows: 
	anchor=\0
	anchor= =
	anchor = =\0

    all inputs above were refused by read_config(). for regular input the
    for valid input the read_config() is doing the right thing.

thanks and
regards
sashan