From 199687610d3bf1b29b7342da40d9306dd46accdc Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 4 Oct 2023 09:09:49 +0100 Subject: win32: fix handling of relative paths Commit 548ec7045b (win32: interpret absolute paths as relative to %SYSTEMDRIVE%) introduced the function xabsolute_path() to make relative paths absolute. This is used in 'dkpg' and 'man' to avoid having to tinker with absolute paths from upstream. Unfortunately, it's too eager to use the relative path. This results in dpkg failing to install deb files with a relative path. Saves 32-48 bytes. (GitHub issue #371) --- win32/mingw.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/win32/mingw.c b/win32/mingw.c index 8588b1a86..977848a2a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -2292,28 +2292,19 @@ int chdir_system_drive(void) * This function is used to make relative paths absolute before a call * to chdir_system_drive(). It's unlikely to be useful in other cases. * - * If the argument is an absolute path or a relative path which resolves - * to a path on the system drive return 'path'. If it's a relative path - * which resolves to a path that isn't on the system drive return an - * allocated string containing the resolved path. Die on failure, + * If the argument is an absolute path return 'path', otherwise return + * an allocated string containing the resolved path. Die on failure, * which is most likely because the file doesn't exist. */ char *xabsolute_path(char *path) { char *rpath; - const char *sd; if (root_len(path) != 0) return path; // absolute path rpath = xmalloc_realpath(path); - if (rpath) { - sd = get_system_drive(); - if (sd && is_prefixed_with_case(rpath, sd)) { - free(rpath); - return path; // resolved path is on system drive - } + if (rpath) return rpath; - } bb_perror_msg_and_die("can't open '%s'", path); } -- cgit v1.2.3-55-g6feb