This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11319] New: dprintf doesn't handle errors proprerly
- From: "kirill at shutemov dot name" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 24 Feb 2010 11:30:31 -0000
- Subject: [Bug libc/11319] New: dprintf doesn't handle errors proprerly
- Reply-to: sourceware-bugzilla at sourceware dot org
According to manpage dprintf(3) (actually return value described in manpage for
printf(3)) should return a negative value, if an output error is encountered.
But dprintf(3) return positive value, if underlying write(2) returns -1 and sets
errno=EINVAL.
$ cat dprintf_test.c
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/eventfd.h>
int main(int argc, char **argv)
{
int ret;
int fd = eventfd(0, 0);
/*
* man 2 eventfd:
*
* A write(2) will fail with the error EINVAL if the size of the supplied
* buffer is less than 8 bytes...
*/
ret = dprintf(fd, "%d", 0);
printf("%d: %s\n", ret, strerror(errno));
return 0;
}
$ gcc -o dprintf_test dprintf_test.c
$ ./dprintf_test
1: Invalid argument
$ strace ./dprintf_test
...
eventfd2(0, 0) = 3
...
write(3, "0", 1) = -1 EINVAL (Invalid argument)
...
--
Summary: dprintf doesn't handle errors proprerly
Product: glibc
Version: 2.11
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: kirill at shutemov dot name
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11319
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.