This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1995] New: fprintf() + fmemopen() error (?)
- From: "michael dot kerrisk at gmx dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Dec 2005 13:34:04 -0000
- Subject: [Bug libc/1995] New: fprintf() + fmemopen() error (?)
- Reply-to: sourceware-bugzilla at sourceware dot org
When run, the program below displays the following output:
$ ./a.out
ret = 19 buf=123456789
However, since the fprintf() is causing an overflow in 'buf'
shouldn't the call be returning -1 as an error indication (as
would happen when fprintf() fails because the disk is full)?
Cheers,
Michael
define _GNU_SOURCE
#include <stdio.h>
int main()
{
char buf[10];
FILE *fp;
int ret;
fp = fmemopen(buf, sizeof(buf), "w");
ret = fprintf(fp, "%s", "1234567890123456789");
fclose(fp);
printf("ret = %d buf=%s\n", ret, buf);
return 0;
}
--
Summary: fprintf() + fmemopen() error (?)
Product: glibc
Version: 2.3.5
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: michael dot kerrisk at gmx dot net
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=1995
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.