bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BUG: printf formatting libc.so.6


From: Bruce Korb
Subject: Re: BUG: printf formatting libc.so.6
Date: Mon, 26 May 2003 08:57:19 -0700

Andreas Schwab wrote:
> 
> Bruce Korb <address@hidden> writes:
> 
> |> /* This program fails */
> 
> No, it doesn't.

Yes, it does:

$ gcc -o broken broken.c
$ ./broken
ch1: 49 ('1') -- ch2: -1073748704 (' ')
$ rcp broken.c ellen:tmp/.
$ rsh ellen
Last login: Mon May 26 07:02:31 from 172.22.12.211
Sun Microsystems Inc.   SunOS 5.8       Generic February 2000
You have mail.
$ cd tmp
$ cc -o working ./broken.c
$ ./working
ch1: 49 ('1') -- ch2: 32 (' ')
$ cat broken.c
#include <stdio.h>

#ifdef USE_SNPRINTFV
#include "config.h"
#include <snprintfv/printf.h>
#endif

static const char zSamp[] =
"ch1: 49 ('1') -- ch2: 32 (' ')\n";
static const char zFmt[] =
"ch1: %1$d ('%1$c') -- ch2: %2$d ('%2$c')\n";

static char zBuff[ 128 ];

int
main( int argc, char** argv )
{
    sprintf( zBuff, zFmt, 0x31, 32 );
    fputs( zBuff, stdout );
    return strcmp( zBuff, zSamp ) != 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]