X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_apply.c;h=3a2c077dab34436c79732ac2be0e9ade33452b8b;hp=faacd718b7e9178e0d00610a7bd4aa57ea1b3313;hb=9f25365263682b2b8cb7ef760d9668157830f566;hpb=b41816aff9a66099bd44c93729c89bbd514f9c3f 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];