This is the mail archive of the
ecos-bugs@sourceware.org
mailing list for the eCos project.
[Bug 1000414] New: snprintf returns a useless value when provided buffer is too small
- From: bugzilla-daemon at ecoscentric dot com
- To: ecos-bugs at sources dot redhat dot com
- Date: Mon, 25 Jun 2007 14:17:45 +0100 (BST)
- Subject: [Bug 1000414] New: snprintf returns a useless value when provided buffer is too small
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.