This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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]

[Bug libc/11595] New: sprintf %% format error resulting in output corruption


The following program produces different output for printf and sprintf. It 
appears the sprintf is being corrupted by the %% in the format string


#include <cstdio>

int main(int ac, char **av)
    {
    char buf[1024];

    printf("%8.4f%%  AAAA\n", 98.3450);
    sprintf(buf, "%8.4f%%  AAAA\n", 98.3450); 
    printf(buf);
    return (0);
    }

The output on my server (Linux analysis-043 2.6.18-92.el5 #1 SMP Tue Jun 10 
18:51:06 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux) is

 98.3450%  AAAA
 98.3450 0X1.896147AE147AEP+6AAA

I think the output should be identical. When %% is present in the sprintf 
format string the output is being corrupted.

-- 
           Summary: sprintf %% format error resulting in output corruption
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: michael dot yacc at blueyonder dot co dot uk
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11595

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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