public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/5424] New: printf doesn't behave correctly with huge numbers of characters
@ 2007-11-28 12:13 vincent+libc at vinc17 dot org
  2007-11-28 13:25 ` [Bug libc/5424] " vincent+libc at vinc17 dot org
  2007-12-10  2:30 ` drepper at redhat dot com
  0 siblings, 2 replies; 3+ messages in thread
From: vincent+libc at vinc17 dot org @ 2007-11-28 12:13 UTC (permalink / raw)
  To: glibc-bugs

When the number of characters is > INT_MAX, printf doesn't return the number of
output characters. The C standard seems to be silent on this point and the
current glibc manual and printf(3) man page are also silent. The following
program was tested on a Debian/etch x86_64 machine:

#ifndef N
#define N 2147483648
#endif

#define STRINGIFY(S) #S
#define MAKE_STR(S) STRINGIFY(S)

#define SN MAKE_STR(N)

#include <stdio.h>

int main (void)
{
  int ret;

  ret = printf ("%" SN "d%" SN "d", 1, 1);
  fprintf (stderr, "ret = %d\n", ret);
  return 0;
}

$ ./ret-printf | wc -c
ret = 0
4294967296

I don't know how such cases should be handled, but returning a non-negative
value different from the number of output characters is incorrect.

Moreover, printf doesn't handle field widths larger than 2^31.

-- 
           Summary: printf doesn't behave correctly with huge numbers of
                    characters
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: vincent+libc at vinc17 dot org
                CC: glibc-bugs at sources dot redhat dot com


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

------- 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] 3+ messages in thread

* [Bug libc/5424] printf doesn't behave correctly with huge numbers of characters
  2007-11-28 12:13 [Bug libc/5424] New: printf doesn't behave correctly with huge numbers of characters vincent+libc at vinc17 dot org
@ 2007-11-28 13:25 ` vincent+libc at vinc17 dot org
  2007-12-10  2:30 ` drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: vincent+libc at vinc17 dot org @ 2007-11-28 13:25 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vincent+libc at vinc17 dot org  2007-11-28 13:25 -------
I found the following with Google:

http://www.opengroup.org/platform/resolutions/bwg98-006.html

"In addition, snprintf() will fail if:
[EOVERFLOW] The value of n is greater than INT_MAX
or the number of bytes needed to hold
the output excluding the terminating
null is greater than INT_MAX."

This is also in a recent POSIX draft (I haven't checked the latest).

-- 


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

------- 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] 3+ messages in thread

* [Bug libc/5424] printf doesn't behave correctly with huge numbers of characters
  2007-11-28 12:13 [Bug libc/5424] New: printf doesn't behave correctly with huge numbers of characters vincent+libc at vinc17 dot org
  2007-11-28 13:25 ` [Bug libc/5424] " vincent+libc at vinc17 dot org
@ 2007-12-10  2:30 ` drepper at redhat dot com
  1 sibling, 0 replies; 3+ messages in thread
From: drepper at redhat dot com @ 2007-12-10  2:30 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2007-12-10 02:30 -------
Overflow check is in cvs.

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


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

------- 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] 3+ messages in thread

end of thread, other threads:[~2007-12-10  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-28 12:13 [Bug libc/5424] New: printf doesn't behave correctly with huge numbers of characters vincent+libc at vinc17 dot org
2007-11-28 13:25 ` [Bug libc/5424] " vincent+libc at vinc17 dot org
2007-12-10  2:30 ` drepper 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).