This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug (?) in sprintf family?


Jeff Johnston <jjohnstn <at> redhat.com> writes:

> 
> Please try the attached patch.  It disconnects the sprintf and sscanf 
> family of functions from bringing in all the I/O stuff.  This is 
> especially useful since tzset drags in sscanf.
> 
> If I missed something, let me know.
> 

With CVS cygwin, asprintf(&str, "%s", "") (or even simpler, asprintf(&str, "")) 
currently dumps core, and I think the cause was this patch.  Meanwhile, 
asnprintf passes; and it looks like the only difference between them is that 
you forgot to modify asnprintf.c to use the new _svfprintf_r instead of 
_vfprintf_r, and that _vfprintf_r operating on a string correctly mallocs even 
for an empty format string.

It seems like the fix would be making sure that in vfprintf.c, when __SMBF is 
set, __sprint_r must allocate a string even if it will not be populating it, 
since asprintf.c depends on the string being pre-allocated large enough to hold 
the trailing NUL.  But I'm still working on building a debugging version of 
cygwin to test this theory.

-- 
Eric Blake



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]