This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Re: Bug in glibc 2 vsnprintf
>>>>> Ulrich Drepper writes:
Uli> Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
>> vsnprintf(s, 10, 12345) returned 5 <- ok
>> vsnprintf(s, 1, 123) returned 3 <- AFAIK not according to the old
>> specification (should be -1)
>> vsnprintf(s, 2, 123) returned -1 <- ok
Uli> I added
Uli> snprintf (buf, 1, "%d", 123);
Uli> to the test suite and do not see a problem. What's a correct test case?
I'm appending a patch against the glibc 2.0 test suite. With this
test case I get the failure.
Andreas
--- stdio-common/tst-printf.c.~1~ Fri Aug 21 07:59:34 1998
+++ stdio-common/tst-printf.c Fri Aug 21 11:03:32 1998
@@ -234,7 +234,9 @@
{
char buf[10];
- int ret = snprintf (buf, 1, "%d", 123);
+ int ret;
+ snprintf (buf, 10, "%d", 123);
+ ret = snprintf (buf, 1, "%d", 123);
printf ("snprintf (buf, 1, \"%%d\", 123) = %d\n", ret);
if (ret != -1)
abort ();
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@alma.student.uni-kl.de