mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
To: Szabolcs Nagy <nsz@port70.net>,
	musl@lists.openwall.com, Markus Wichmann <nullplan@gmx.net>
Subject: Re: [musl] Invalid read of nl_arg in printf_core()
Date: Sat, 05 Nov 2022 07:52:09 -0400	[thread overview]
Message-ID: <1667648794.ymyp54wny2.none@localhost> (raw)
In-Reply-To: <20221105100936.GC98588@port70.net>

Excerpts from Szabolcs Nagy's message of November 5, 2022 6:09 am:
> * Markus Wichmann <nullplan@gmx.net> [2022-11-03 20:42:16 +0100]:
>> Hi all,
>> 
>> reading some code today, I noticed undefined behavior in printf_core().
>> vfprintf() creates an array called nl_arg automatically and does not
>> initialize it. That is fine, but it means that reads from each array
>> member are undefined behavior until that member gets assigned a value.
> 
> an automatic storage object that was not initialized has indeterminate
> value, so accessing it is not undefined behaviour. (unless the object
> could have been declared with the register storage class)
> 
> so technically the code is correct (if int has no trap representations)
> but i think the fix still makes sense: leaving unspecified values around
> is error prone.

N1570 J.2 [Undefined behavior]:

1   The behavior is undefined in the following circumstances:
[ ... ]
— The value of an object with automatic storage duration is used while it is
  indeterminate (6.2.4, 6.7.9, 6.8).

  reply	other threads:[~2022-11-05 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 19:42 Markus Wichmann
2022-11-05 10:09 ` Szabolcs Nagy
2022-11-05 11:52   ` Alex Xu (Hello71) [this message]
2022-11-05 12:30     ` Jₑₙₛ Gustedt

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=1667648794.ymyp54wny2.none@localhost \
    --to=alex_y_xu@yahoo.ca \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    --cc=nullplan@gmx.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).