This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] vfscanf: Avoid multiple reads of multi-byte character width
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: fweimer at redhat dot com (Florian Weimer)
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 02 Sep 2016 15:56:17 +0200
- Subject: Re: [PATCH] vfscanf: Avoid multiple reads of multi-byte character width
- Authentication-results: sourceware.org; auth=none
- References: <20160902131953.69ABB40191DBC@oldenburg.str.redhat.com>
On Sep 02 2016, fweimer@redhat.com (Florian Weimer) wrote:
> diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
> index 8cd5955..2b7093e 100644
> --- a/stdio-common/vfscanf.c
> +++ b/stdio-common/vfscanf.c
> @@ -757,7 +757,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
> size_t n;
>
> if (!(flags & SUPPRESS) && (flags & POSIX_MALLOC)
> - && str + MB_CUR_MAX >= *strptr + strsize)
> + && MB_LEN_MAX >= *strptr + strsize - str)
Please reorder the condition to put the constant part on the right hand
side (also below).
Ok with that change.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."