From: Miles Bader Date: Thu, 25 Apr 1996 21:37:46 +0000 (+0000) Subject: (__getcwd): When we find a match in the scan for a name, avoid doing another readdi... X-Git-Tag: cvs/libc-960426~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=072d114510658495a9f241864e0194d542b47a08;p=platform%2Fupstream%2Fglibc.git (__getcwd): When we find a match in the scan for a name, avoid doing another readdir (which overwrites NENTRIES, and was resulting in a bogus ENOENT). --- diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c index abec22c..039f134 100644 --- a/sysdeps/mach/hurd/getcwd.c +++ b/sysdeps/mach/hurd/getcwd.c @@ -119,6 +119,7 @@ __getcwd (char *buf, size_t size) unsigned int dirdatasize; int direntry, nentries; + /* Look at the parent directory. */ newp = __file_name_lookup_under (parent, "..", O_READ, 0); if (newp == MACH_PORT_NULL) @@ -187,6 +188,11 @@ __getcwd (char *buf, size_t size) break; } } + + if (offset < dirdatasize) + /* We got a match; avoid doing another dir_readdir, which will + hose NENTRIES. */ + break; } if (err)