scanf() is not working properly with latest snapshot of newlib.

Jeff Johnston jjohnstn@redhat.com
Tue Aug 21 20:58:00 GMT 2007


Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to Bhushan Attarde on 8/20/2007 12:59 AM:
>> int main ( void )
>> {          
>>  char string[10];
>>  
>>  while(1)
>>  {
>>    scanf("%s",&string);
> 
> Unrelated to your report, but please fix your bug.  Don't go reading
> unlimited length strings into a fixed-width buffer using scanf.
> 
>> Anyone have any idea about this?
> 
> What platform are you targetting?
> 

FWIW: I just did a full rebuild of mn10300-elf and running under the 
mn10300-elf simulator, the test-case above works fine.  Note that the 
simulator is obviously seeing the read syscall.  The test also works for 
x86-linux.

By any chance are you using PPC?  There are machine-specific versions 
for vfscanf and vfprintf and possibly they are out of sync.

-- Jeff J.

> - --
> Don't work too hard, make some time for fun as well!
> 
> Eric Blake             ebb9@byu.net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Cygwin)
> Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFGyYT684KuGfSFAYARAkazAKDDZnsbHakJtsMriI/y4T5NGJca3gCgorBA
> cSY2ugTOKRRhOOtwS5LUwlU=
> =e4r+
> -----END PGP SIGNATURE-----



More information about the Newlib mailing list