public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org, Florian Weimer <fw@deneb.enyo.de>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [PATCH] Fix aliasing violation in __vfscanf_internal [BZ #26690]
Date: Wed, 7 Oct 2020 15:10:24 -0300	[thread overview]
Message-ID: <6a8269f0-e514-22e4-d64e-b93986298577@linaro.org> (raw)
In-Reply-To: <87lfgh52pm.fsf@mid.deneb.enyo.de>



On 07/10/2020 15:08, Florian Weimer wrote:
> * Szabolcs Nagy via Libc-alpha:
> 
>> diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
>> index 95b46dcbeb..d832493623 100644
>> --- a/stdio-common/vfscanf-internal.c
>> +++ b/stdio-common/vfscanf-internal.c
>> @@ -135,6 +135,16 @@
>>  
>>  #include "printf-parse.h" /* Use read_int.  */
>>  
>> +/* Same as read_int, but for CHAR_T * instead of UCHAR_T * string.  */
>> +static int
>> +read_int_char (const CHAR_T * *pstr)
>> +{
>> +  const UCHAR_T *ustr = (const UCHAR_T *) *pstr;
>> +  int retval = read_int (&ustr);
>> +  *pstr = (const CHAR_T *) ustr;
>> +  return retval;
>> +}
>> +
>>  #define encode_error() do {						      \
>>  			  __set_errno (EILSEQ);				      \
>>  			  goto errout;					      \
>> @@ -486,7 +496,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
>>        /* Check for a positional parameter specification.  */
>>        if (ISDIGIT ((UCHAR_T) *f))
>>  	{
>> -	  argpos = read_int ((const UCHAR_T **) &f);
>> +	  argpos = read_int_char (&f);
>>  	  if (*f == L_('$'))
>>  	    ++f;
>>  	  else
>> @@ -522,7 +532,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
>>        /* Find the maximum field width.  */
>>        width = 0;
>>        if (ISDIGIT ((UCHAR_T) *f))
>> -	width = read_int ((const UCHAR_T **) &f);
>> +	width = read_int_char (&f);
>>      got_width:
>>        if (width == 0)
>>  	width = -1;
> 
> Patch and commit message look reasonable to me.  Thanks.
> 

Andreas has sent a similar fix for the same issue [1]. Is it something
wrong with his fix? It seems to cover more aliasing violation 

[1] https://sourceware.org/pipermail/libc-alpha/2020-October/118149.html

  reply	other threads:[~2020-10-07 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07 17:50 Szabolcs Nagy
2020-10-07 18:08 ` Florian Weimer
2020-10-07 18:10   ` Adhemerval Zanella [this message]
2020-10-07 18:16     ` Florian Weimer
2020-10-08  7:27       ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a8269f0-e514-22e4-d64e-b93986298577@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fw@deneb.enyo.de \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).