public inbox for ecos-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug 1000414]  New: snprintf returns a useless value when provided buffer is too small
@ 2007-06-25 13:17 bugzilla-daemon
  0 siblings, 0 replies; only message in thread
From: bugzilla-daemon @ 2007-06-25 13:17 UTC (permalink / raw)
  To: ecos-bugs

https://bugzilla.ecoscentric.com/show_bug.cgi?id=1000414

           Summary: snprintf returns a useless value when provided buffer is
                    too small
           Product: eCos
           Version: CVS
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: normal
         Component: C library
        AssignedTo: jifl@ecoscentric.com
        ReportedBy: nicolas.schodet@spidcom.com
         QAContact: ecos-bugs@sources.redhat.com


When the provided buffer is too small, ecos snprintf returns the number of
characters written, not the number of characters which would have been
written.

Given the following program:

#include <stdio.h>
int
main (void)
{
    char buf[6];
    printf ("short => %d\n",
            snprintf (buf, sizeof (buf) / sizeof (buf[0]), "short"));
    printf ("longer => %d\n",
            snprintf (buf, sizeof (buf) / sizeof (buf[0]), "longer"));
    return 0;
}

With GNU libc:

short => 5
longer => 6

With eCos libc:

short => 5
longer => 5

There is no way to know that the output was truncated.

-- 
Configure bugmail: https://bugzilla.ecoscentric.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-25 13:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-25 13:17 [Bug 1000414] New: snprintf returns a useless value when provided buffer is too small bugzilla-daemon

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).