From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12299 invoked by alias); 24 Feb 2010 11:30:46 -0000 Received: (qmail 12147 invoked by uid 48); 24 Feb 2010 11:30:31 -0000 Date: Wed, 24 Feb 2010 11:30:00 -0000 From: "kirill at shutemov dot name" To: glibc-bugs@sources.redhat.com Message-ID: <20100224113031.11319.kirill@shutemov.name> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/11319] New: dprintf doesn't handle errors proprerly X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00100.txt.bz2 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 #include #include #include 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.