This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: scandir issue on RTEMS
- From: "Howland Craig D (Craig)" <howland at LGSInnovations dot com>
- To: "Joel Sherrill" <joel dot sherrill at oarcorp dot com>, <newlib at sources dot redhat dot com>
- Date: Thu, 19 Mar 2009 13:06:41 -0400
- Subject: RE: scandir issue on RTEMS
- References: <49C26DB5.7080701@oarcorp.com>
Joel:
It seems like the user's report was meant to be attached but was
not.
I was searching for MAXNAMLEN a while ago, and did not find
anything standard--although I could have missed it. The best that I
could tell is that NAME_MAX (from POSIX) is what ought to be used in
dirent.h. NAME_MAX should be defined in limits.h. If a MAXNAMLEN (I
did
not find MAXNAMELEN in Newlib) is needed to be compatible with old
oddball
code that people have from somewhere, a suggestion is that it should be
in
limits.h to be the same as NAME_MAX (i.e. #define MAXNAMLEN NAME_MAX).
(Another related puzzle is how NAME_MAX relates to C's
FILENAME_MAX.)
Craig
-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Joel Sherrill
Sent: Thursday, March 19, 2009 12:07 PM
To: newlib@sources.redhat.com
Subject: scandir issue on RTEMS
Hi,
I got this report from a user and wondered if someone
could provide a recommendation. I am getting wrapped
around the axle trying to figure out what should be
set by whom where.
It is used in scandir() (newlib-1.17.0/newlib/libc/posix/scandir.c:117)
by the macro DIRSIZ. Where DIRSIZ uses the MAXNAMELEN define which is
set incorrectly. It does not match the sizeof(struct dirent) which makes
the DIRSIZ return a negative number, then malloc(DIRSIZ(d)) will try to
allocate 4GB which fail.
My guess is that MAXNAMELEN should be defined in
newlib-1.17.0/newlib/libc/sys/rtems/sys/dirent.h or
newlib-1.17.0/newlib/libc/sys/rtems/include/limits.h or in a new file.
--
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