From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20853 invoked by alias); 3 Oct 2011 23:52:28 -0000 Received: (qmail 20845 invoked by uid 22791); 3 Oct 2011 23:52:27 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_JG X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Oct 2011 23:52:15 +0000 From: "jg at jguk dot org" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/9819] readdir segmentation faults when passed NULL Date: Mon, 03 Oct 2011 23:52:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jg at jguk dot org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2011-10/txt/msg00004.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=9819 --- Comment #4 from Jon Grant 2011-10-03 23:51:27 UTC --- Rich, I've heard that argument before; I'm not convinced though. I'm not sure if I'm missing something though. Could I ask why returning -1, and setting errno to EFAULT when readdir passed NULL would hide bugs? My view was that it actually highlights them very clearly to the application. Re stdio, yes, some already are stable: take printf as a good example in glibc, it is safe and robust. A NULL pointer won't cause a crash, it checks its parameters, returning -1, and setting errno to EINVAL. Contrast printf with puts, which SEGV currently. NULL is a special case, as it's the value people initialise their pointers, and after releasing memory also set NULL. If pointers are not going to checked, the same could be applied to file handles, letting them cause crashes. Currently passing read() a bad fd, is robustly handled by setting EBADF in errno and returning -1. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.