Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Thu, 21 Mar 2024 18:27:34 -0400
From: Rich Felker <dalias@...ifal.cx>
To: Maks Mishin <maks.mishinfz@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] vfscanf: Remove if-condition with unused value

On Thu, Mar 21, 2024 at 11:40:14PM +0300, Maks Mishin wrote:
> Remove else branch because the value of 'c' is unused.
> 
> Found by RASU JSC.
> 
> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> ---
>  src/stdio/vfscanf.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
> index b78a374d..fad88553 100644
> --- a/src/stdio/vfscanf.c
> +++ b/src/stdio/vfscanf.c
> @@ -263,8 +263,6 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
>  			} else if ((s = dest)) {
>  				while (scanset[(c=shgetc(f))+1])
>  					s[i++] = c;
> -			} else {
> -				while (scanset[(c=shgetc(f))+1]);
>  			}
>  			shunget(f);
>  			if (!shcnt(f)) goto match_fail;
> -- 
> 2.30.2

Did you even test this? The patch removes code with side effects and
completely breaks %*[scanset] conversion specifiers by turning them
into effective no-ops.

The analysis tool was telling you the assignment to c is unused, not
that the calls to shgetc can just be thrown away.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.