This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/1995] New: fprintf() + fmemopen() error (?)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]