public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11319] New: dprintf doesn't handle errors proprerly
@ 2010-02-24 11:30 kirill at shutemov dot name
2010-02-25 0:09 ` [Bug libc/11319] " drepper at redhat dot com
0 siblings, 1 reply; 2+ messages in thread
From: kirill at shutemov dot name @ 2010-02-24 11:30 UTC (permalink / raw)
To: glibc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-25 0:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-24 11:30 [Bug libc/11319] New: dprintf doesn't handle errors proprerly kirill at shutemov dot name
2010-02-25 0:09 ` [Bug libc/11319] " drepper at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).