public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] readdir doesn't handle NULL "DIR *" case correctly
@ 2003-12-12 13:03 sandeep
  0 siblings, 0 replies; only message in thread
From: sandeep @ 2003-12-12 13:03 UTC (permalink / raw)
  To: ecos-discuss

Hi nickg,

while trying out romfs test (the rom-image used for the test *didn't contain etc
folder*) it was found that readdir function doesn't handle "readdir(NULL)" call
correctly leading to variety of buggy behaviours later.

romfs/tests/fileio1.c:
--------------------
static void listdir( char *name, int statp )
{
    int err;
    DIR *dirp;

    diag_printf("<INFO>: reading directory %s\n",name);

    dirp = opendir( name );
    if( dirp == NULL ) SHOW_RESULT( opendir, -1 );

    for(;;)
    {
        struct dirent *entry = readdir( dirp );

        if( entry == NULL )
            break;
==== snipped =========

in listdir ("/etc",true) call :  opendir("/etc") correctly returned NULL in
mentioned case. however
the for-loop below that never ended as readdir call never returned NULL.

What about the solution - wherein we check the argument to readdir for NULL in
the beginning itself and handle it elegantly there itself? or would you prefer
this to be done in readdir_r function called by this function?

Also it looks like (io/fileio/current/src/dir.cxx) readdir function is not
thread-safe courtesy "static struct dirent ent" ? am i missing something here?

peace
sandeep


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-12-12 12:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-12 13:03 [ECOS] readdir doesn't handle NULL "DIR *" case correctly sandeep

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).