Message-Id: <199907091623.QAA17776@out5.ibm.net> From: "Mark E." To: djgpp-workers AT delorie DOT com Date: Fri, 9 Jul 1999 12:23:23 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: patch for access.c X-mailer: Pegasus Mail for Win32 (v3.11) Reply-To: djgpp-workers AT delorie DOT com Currently, access can leak a handle under LFN when checking a root directory on a "non-local" drive. This patch fixes this by closing the LFN handle before returning. I also changed attr to an int to silence a comparison warning (_chmod returns an int but attr was unsigned). *** src/libc/posix/unistd/access.c.orig Thu Jan 1 17:04:26 1998 --- src/libc/posix/unistd/access.c Fri Jul 9 12:15:30 1999 *************** *** 11,17 **** int access(const char *fn, int flags) { ! unsigned attr = _chmod(fn, 0); if (attr == -1) { struct ffblk ff; --- 11,17 ---- int access(const char *fn, int flags) { ! int attr = _chmod(fn, 0); if (attr == -1) { struct ffblk ff; *************** int access(const char *fn, int flags) *** 28,36 **** *fp++ = '.'; *fp++ = '*'; *fp++ = '\0'; ! /* Under LFN, we lose a handle here. Solutions, anyone? */ if (findfirst(fixed_path, &ff, FA_DIREC) == 0) return 0; } /* Devices also fail `_chmod'; some programs won't write to --- 28,40 ---- *fp++ = '.'; *fp++ = '*'; *fp++ = '\0'; ! /* Use _lfn_close_handle so we don't lose a handle. */ if (findfirst(fixed_path, &ff, FA_DIREC) == 0) + { + if (strcmp(ff.lfn_magic, "LFN32") == 0) + _lfn_find_close(ff.lfn_handle); return 0; + } } /* Devices also fail `_chmod'; some programs won't write to *************** int access(const char *fn, int flags) *** 38,44 **** --- 42,52 ---- if (findfirst(fn, &ff, FA_RDONLY | FA_ARCH) == 0 && (ff.ff_attrib & 0x40) == 0x40 && (flags & (X_OK | D_OK)) == 0) + { + if (strcmp(ff.lfn_magic, "LFN32") == 0) + _lfn_find_close(ff.lfn_handle); return 0; + } errno = ENOENT; return -1; --- Mark Elbrecht, snowball3 AT bigfoot DOT com http://snowball.frogspace.net/