aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-10-10 15:15:43 +0100
committerRon Yorston <rmy@pobox.com>2024-10-10 15:15:43 +0100
commitf84964d647e3a58905f5692dfdb9319dc170bb88 (patch)
tree90b7445430e10ed18ae1812cfd6051ed8ac1285b /win32
parentc052d1180ec8a9d94a7bd6a64dd7b986ad1a5104 (diff)
downloadbusybox-w32-f84964d647e3a58905f5692dfdb9319dc170bb88.tar.gz
busybox-w32-f84964d647e3a58905f5692dfdb9319dc170bb88.tar.bz2
busybox-w32-f84964d647e3a58905f5692dfdb9319dc170bb88.zip
win32: fix regression in chdir(2)
When mingw_chdir() was introduced it canonicalised its argument (585d17d26). This had the side effect of making its case match that of the directory as stored on disk. Subsequent changes retained that behaviour for symlinks but not otherwise (69d328022, b99032390). This was noted to affect the appearance of the directory specified by the (undocumented) 'sh -d' option. Fix the case of non-symlink directories too. Adds 16-32 bytes.
Diffstat (limited to 'win32')
-rw-r--r--win32/mingw.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index d323014b7..87e7ca602 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -1767,16 +1767,18 @@ int mingw_mkdir(const char *path, int mode UNUSED_PARAM)
1767int mingw_chdir(const char *dirname) 1767int mingw_chdir(const char *dirname)
1768{ 1768{
1769 int ret = -1; 1769 int ret = -1;
1770 const char *realdir = dirname; 1770 char *realdir;
1771 1771
1772 if (is_symlink(dirname)) { 1772 if (is_symlink(dirname))
1773 realdir = auto_string(xmalloc_realpath(dirname)); 1773 realdir = xmalloc_realpath(dirname);
1774 if (realdir) 1774 else
1775 fix_path_case((char *)realdir); 1775 realdir = xstrdup(dirname);
1776 }
1777 1776
1778 if (realdir) 1777 if (realdir) {
1778 fix_path_case(realdir);
1779 ret = chdir(realdir); 1779 ret = chdir(realdir);
1780 }
1781 free(realdir);
1780 1782
1781 return ret; 1783 return ret;
1782} 1784}