From 93eba3cb600c4eb06a535d47137e775f4042c456 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 27 Nov 2003 23:27:23 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_disk_file::readdir): Reorganize to avoid inappropriate .lnk extensions with munged filenames under managed mode. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fhandler_disk_file.cc | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ad11c505a..992d56feb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2003-11-27 Christopher Faylor + + * fhandler_disk_file.cc (fhandler_disk_file::readdir): Reorganize to + avoid inappropriate .lnk extensions with munged filenames under managed + mode. + 2003-11-26 Corinna Vinschen * sec_helper.cc (set_process_privilege): Rename restore_priv to diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index e19c1961f..faebc4511 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -704,29 +704,29 @@ fhandler_disk_file::readdir (DIR *dir) return res; } - /* We get here if `buf' contains valid data. */ - if (get_encoded ()) - (void) fnunmunge (dir->__d_dirent->d_name, buf.cFileName); - else - strcpy (dir->__d_dirent->d_name, buf.cFileName); - /* Check for Windows shortcut. If it's a Cygwin or U/WIN symlink, drop the .lnk suffix. */ if (buf.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { - char *c = dir->__d_dirent->d_name; + char *c = buf.cFileName; int len = strlen (c); if (strcasematch (c + len - 4, ".lnk")) { char fbuf[CYG_MAX_PATH + 1]; strcpy (fbuf, dir->__d_dirname); - strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name); + strcpy (fbuf + strlen (fbuf) - 1, c); path_conv fpath (fbuf, PC_SYM_NOFOLLOW); if (fpath.issymlink () || fpath.isspecial ()) c[len - 4] = '\0'; } } + /* We get here if `buf' contains valid data. */ + if (get_encoded ()) + (void) fnunmunge (dir->__d_dirent->d_name, buf.cFileName); + else + strcpy (dir->__d_dirent->d_name, buf.cFileName); + dir->__d_position++; res = dir->__d_dirent; syscall_printf ("%p = readdir (%p) (%s)",