This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: seekdir dereferences null
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: "newlib at sources dot redhat dot com" <newlib at sources dot redhat dot com>
- Date: Wed, 3 Dec 2008 14:46:51 -0600
- Subject: Re: seekdir dereferences null
- References: <4936EF95.1080408@oarcorp.com>
Patch attached this time. :)
Joel Sherrill wrote:
Hi,
Another bug picked up by the RTEMS test suite.
seekdir(NULL, 0) core dumps.
2008-12-03 Joel Sherrill <joel.sherrill@oarcorp.com>
* libc/posix/telldir.c (_seekdir): Do not dereference NULL dirp.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
Index: libc/posix/telldir.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/telldir.c,v
retrieving revision 1.6
diff -u -r1.6 telldir.c
--- libc/posix/telldir.c 27 Nov 2008 21:01:40 -0000 1.6
+++ libc/posix/telldir.c 3 Dec 2008 20:40:40 -0000
@@ -121,6 +121,9 @@
struct dirent *dp;
extern long lseek();
+ if ( !dirp )
+ return;
+
#ifdef HAVE_DD_LOCK
__lock_acquire(dd_hash_lock);
#endif