This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/16069] New: printf rountines do not set errno for out of memory condition.
- From: "neleai at seznam dot cz" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 21 Oct 2013 14:47:07 +0000
- Subject: [Bug stdio/16069] New: printf rountines do not set errno for out of memory condition.
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16069
Bug ID: 16069
Summary: printf rountines do not set errno for out of memory
condition.
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
Assignee: unassigned at sourceware dot org
Reporter: neleai at seznam dot cz
Hi, after browsing a vfprintf code I found that most error conditions do not
set errno.
A simple example that causes oom condition by changing malloc to one that
always returns null is following.
#define _GNU_SOURCE
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <locale.h>
char *malloc0 (size_t s)
{
return NULL;
}
char s[1000001];
int main()
{
setlocale (LC_ALL, "en_US.UTF8");
int i;
FILE *f = fopen ("foo", "w");
for (i = 0; i<1000000; i++)
s[i] = 'x';
s[1000000] = 0;
__malloc_hook = malloc0;
int c = fwprintf (f, L"%s", s);
if (errno != ENOMEM)
abort ();
}
--
You are receiving this mail because:
You are on the CC list for the bug.