This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/649] New: printf("%.*s", str) bug in a Qt application, also sprintf(s, "%.*s", str) bug
- From: "develop at durst dot de" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 11 Jan 2005 09:35:32 -0000
- Subject: [Bug libc/649] New: printf("%.*s", str) bug in a Qt application, also sprintf(s, "%.*s", str) bug
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
If the following program is built on SUSE LINUX 9.1 or newer then
the sprintf and printf calls result in an empty string to be written
if characters from ASCII 128-255 occur in the source string:
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <qapplication.h>
int main( int argc, char** argv )
{
QApplication app( argc, argv ); // necessary to produce the bug
char str[256], s[256];
while (fgets(str, 250, stdin))
{
sprintf(s, "%.*s", 66, str);
if (strncmp(s, str, 66))
{
printf("str: %.66s ", str); // str not written
printf(" strings differ, seems sprintf bug\n");
}
else
printf("str: %.66s ", str);
}
return 0;
}
Build with: g++ test.cpp -o teste -I/usr/local/qt/include /usr/lib/libqt-mt.so.3
Run with: teste <test.txt
Contents of test.txt:
test 75 24234 k ä 77
test 75 24234 k ö 77
test 75 24234 k ü 77
test 75 24234 k ß 77
test 75 24234 k Ä 77
test 75 24234 k Ö 77
test 75 24234 k Ü 77
test 75 24234 k ° 77
test 75 24234 k ± 77
test 75 24234 k ² 77
test 75 24234 k µ 77
test 75 24234 k ~ 77
--
Summary: printf("%.*s", str) bug in a Qt application, also
sprintf(s, "%.*s", str) bug
Product: glibc
Version: 2.3.3
Status: NEW
Severity: normal
Priority: P1
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: develop at durst dot de
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-suse-linux
GCC host triplet: i686-suse-linux
GCC target triplet: i686-suse-linux
http://sources.redhat.com/bugzilla/show_bug.cgi?id=649
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.