This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/9819] readdir segmentation faults when passed NULL
- From: "jg at jguk dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Mon, 03 Oct 2011 23:51:27 +0000
- Subject: [Bug libc/9819] readdir segmentation faults when passed NULL
- Auto-submitted: auto-generated
- References: <bug-9819-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=9819
--- Comment #4 from Jon Grant <jg at jguk dot org> 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.