[En-Nut-Discussion] ReadDir fail, wrong retcode in PhatDirEntryRead ?

Harald Kipp harald.kipp at egnite.de
Wed Jan 25 19:09:40 CET 2006


In a simplified way: Yes, I agree.

In fact this is a bit more complicated, as all routines clearly
determine between an error and the end of a directory. Though,
the implementation of readdir() is wrong, because the manual
page specifies "It returns NULL on reaching the end-of-file or
if an error occurred."

ftpserv deals with this wrong implementation, checking for an
empty name. Changing PhatDirEntryRead() following your suggestion
will make this and other code (e.g. in PhatDirEntryFind)
unnecessary.

That was the complicated part of my acceptance. :-)

Harald


At 17:11 25.01.2006 +0100, you wrote:

>In PhatDirEntryRead, the return code is 0 if the end of the directory is 
>found. This causes (at least) ReadDir to fail or, more correctly, to never 
>terminate. The correct return code should have been -1, IMHO.
>
>snippet from PhatDirEntryRead
>
>   } else {
>     /* End marker found. */
>     srch->phfind_name[0] = 0;
>     return -1; <<<<<<<<<<<<<<<<<< shouldn't this have been here ?
>   }
>   break;




More information about the En-Nut-Discussion mailing list