From: Eric Biggers Date: Thu, 11 Feb 2016 01:55:35 +0000 (-0600) Subject: win32_apply.c: don't add extra slash to link target X-Git-Tag: v1.9.1~38 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=9f25365263682b2b8cb7ef760d9668157830f566 win32_apply.c: don't add extra slash to link target --- diff --git a/src/win32_apply.c b/src/win32_apply.c index faacd718..3a2c077d 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2013, 2014, 2015 Eric Biggers + * Copyright (C) 2013-2016 Eric Biggers * * This file is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -2109,6 +2109,17 @@ try_rpfix(struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_p, target_ntpath_nchars = ctx->target_ntpath.Length / sizeof(wchar_t); + /* If the target directory is a filesystem root, such as \??\C:\, then + * it already will have a trailing slash. Don't include this slash if + * we are already adding slashes via 'relpath'. This prevents an extra + * slash from being generated each time the link is extracted. And + * unlike on UNIX, the number of slashes in paths on Windows can be + * significant; Windows won't understand the link target if it contains + * too many slashes. */ + if (target_ntpath_nchars > 0 && relpath_nchars > 0 && + ctx->target_ntpath.Buffer[target_ntpath_nchars - 1] == L'\\') + target_ntpath_nchars--; + fixed_subst_name_nchars = target_ntpath_nchars + relpath_nchars; wchar_t fixed_subst_name[fixed_subst_name_nchars];