This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11923] New: sprintf - %#02x doesnt expand to 0x00 if the value 0 is used
- From: "almrobert at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 18 Aug 2010 13:27:00 -0000
- Subject: [Bug libc/11923] New: sprintf - %#02x doesnt expand to 0x00 if the value 0 is used
- Reply-to: sourceware-bugzilla at sourceware dot org
First of all, I have libc.2.11, running Ubuntu 10.04 with GCC (gcc (Ubuntu
4.4.3-4ubuntu5) 4.4.3). I suppose this is the correct libc.... I have not tested
the latest source of libc.
Running the following example code:
#include <stdio.h>
#include <stdlib.h>
#define TEST_SPRINTF "asdf.%#08x.%#02x.%#04x.%#02x.asdf"
#define TEST_SPRINTF2 "asdf.0x%08x.0x%02x.0x%04x.0x%02x.asdf"
int main(void) {
char test[128];
unsigned int value1 = 0x12345678;
int value2 = 0x00;
int value3 = 0x0012;
int value4 = 0x1234;
sprintf(test, TEST_SPRINTF, value1, value2, value3, value4);
printf("%s\n", test);
sprintf(test, TEST_SPRINTF2, value1, value2, value3, value4);
printf("%s\n", test);
return EXIT_SUCCESS;
}
Gives the following output:
asdf.0x12345678.00.0x12.0x1234.asdf
asdf.0x12345678.0x00.0x0012.0x1234.asdf
The second row is as supposed to while the first row is missing 0x and 00
--
Summary: sprintf - %#02x doesnt expand to 0x00 if the value 0 is
used
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: almrobert at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11923
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.