public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11595] New: sprintf %% format error resulting in output corruption
@ 2010-05-13 11:40 michael dot yacc at blueyonder dot co dot uk
  2010-05-13 11:46 ` [Bug libc/11595] " jakub at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: michael dot yacc at blueyonder dot co dot uk @ 2010-05-13 11:40 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug libc/11595] sprintf %% format error resulting in output corruption
  2010-05-13 11:40 [Bug libc/11595] New: sprintf %% format error resulting in output corruption michael dot yacc at blueyonder dot co dot uk
@ 2010-05-13 11:46 ` jakub at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at redhat dot com @ 2010-05-13 11:46 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2010-05-13 11:46 -------
No, the testcase is invalid.  In the second printf you pass in %  AAAA
in the format string, which means that a double argument of that printf (none
was provided) is printed in hexadecimal notation, followed by AAA.
You should use printf ("%s", buf); or fputs etc.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-13 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-13 11:40 [Bug libc/11595] New: sprintf %% format error resulting in output corruption michael dot yacc at blueyonder dot co dot uk
2010-05-13 11:46 ` [Bug libc/11595] " jakub at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).