This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix errno codes set by opendir() in case of problems with the path argument


On Mon, Mar 03, 2014 at 10:34:59PM +0400, Oleg Kravtsov wrote:
>Currently cygwin has a problem with errno code set by opendir() 
>function. It always sets errno to ENOENT.
>After applying the path opendir() sets errno to 'ENAMETOOLONG' when path 
>or a path component is too long,
>'ELOOP' when a loop of symbolic links exits in the path.
>
>Best regards,
>Oleg
>
>2014-02-18  Oleg Kravtsov <Oleg.Kravtsov@oktetlabs.ru>
>
>        * dir.cc (opendir): Set errno code depending on the type of an error
>        instead of always setting it to ENOENT.

Thanks for the patch but I don't see any reason for a goto here.  Also
you seem to be skipping over a free which could result in a memory leak.

I think the below should do the same thing without those limitations.

Does it work for you?

cgf

Index: dir.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v
retrieving revision 1.136
diff -d -u -p -r1.136 dir.cc
--- dir.cc	31 Jan 2014 19:27:26 -0000	1.136
+++ dir.cc	3 Mar 2014 19:31:30 -0000
@@ -58,6 +58,11 @@ opendir (const char *name)
   fh = build_fh_name (name, PC_SYM_FOLLOW);
   if (!fh)
     res = NULL;
+  else if (fh->error ())
+    {
+      set_errno (fh->error ());
+      res = NULL;
+    }
   else if (fh->exists ())
     res = fh->opendir (-1);
   else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]