fprintf() crashes on wide-oriented stream.
Takashi Yano
takashi.yano@nifty.ne.jp
Thu Oct 5 15:18:59 GMT 2023
On Thu, 5 Oct 2023 19:18:14 +0900
Takashi Yano wrote:
> Hi Jeff,
>
> Thanks for reviewing and the comment.
>
> On Wed, 4 Oct 2023 16:16:13 -0400
> Jeff Johnston wrote:
> > I finally took a look at this. The issue is whether POSIX compliance is
> > desired.
>
> IIUC, POSIX states that width setting is once decided, it cannot be
> changed until the stream is closed. However, nothing is stated what
> should happen when different width data is output into the stream.
>
> > Corinna would have
> > strong opinions that it is desired and thus, I think she should have her
> > say when she gets back. I personally believe that
> > newlib should have behaved like glibc. I also think the test snippet is
> > invalid and should have performed an fwide call on stdout
> > to reset the wide-orientation and have the code work properly in all cases.
>
> Currently, fputs and fputc works even for wide-oriended stream, so to
> be consistent with that, fprintf also might be better to work.
>
> I wouldn't necessarily expect fprintf to work on wide-oriented streams,
> but buffer overruns should not happen anyway.
>
> So, newlib should be fixed either way.
As a test, I made a patch attached to make it behave like glibc.
What do you think?
--
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: v3-0001-newlib-libc-Fix-crash-on-fprintf-to-a-wide-orient.patch
URL: <https://sourceware.org/pipermail/newlib/attachments/20231006/faf761dd/attachment.ksh>
More information about the Newlib
mailing list