diff options
-rw-r--r-- | win32/mingw.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 79aaa86f1..5e743d94a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1335,7 +1335,11 @@ static REPARSE_DATA_BUFFER *make_junction_data_buffer(char *rpath) | |||
1335 | 1335 | ||
1336 | /* We need two strings for the reparse data. The PrintName is the | 1336 | /* We need two strings for the reparse data. The PrintName is the |
1337 | * target path in Win32 format, the SubstituteName is the same in | 1337 | * target path in Win32 format, the SubstituteName is the same in |
1338 | * NT format. */ | 1338 | * NT format. |
1339 | * | ||
1340 | * The return value from MultiByteToWideChar includes the trailing | ||
1341 | * L'\0' character. | ||
1342 | */ | ||
1339 | slash_to_bs(rpath); | 1343 | slash_to_bs(rpath); |
1340 | plen = MultiByteToWideChar(CP_ACP, 0, rpath, -1, pbuf, PATH_MAX); | 1344 | plen = MultiByteToWideChar(CP_ACP, 0, rpath, -1, pbuf, PATH_MAX); |
1341 | if (plen == 0) { | 1345 | if (plen == 0) { |
@@ -1344,7 +1348,7 @@ static REPARSE_DATA_BUFFER *make_junction_data_buffer(char *rpath) | |||
1344 | } | 1348 | } |
1345 | slen = plen + 4; | 1349 | slen = plen + 4; |
1346 | 1350 | ||
1347 | rbufsize = (slen + plen + 2) * sizeof(WCHAR) + | 1351 | rbufsize = (slen + plen) * sizeof(WCHAR) + |
1348 | FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer); | 1352 | FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer); |
1349 | rptr = xzalloc(rbufsize); | 1353 | rptr = xzalloc(rbufsize); |
1350 | 1354 | ||
@@ -1353,13 +1357,13 @@ static REPARSE_DATA_BUFFER *make_junction_data_buffer(char *rpath) | |||
1353 | FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer); | 1357 | FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer); |
1354 | /* rptr->Reserved = 0; */ | 1358 | /* rptr->Reserved = 0; */ |
1355 | /* MRPB.SubstituteNameOffset = 0; */ | 1359 | /* MRPB.SubstituteNameOffset = 0; */ |
1356 | MRPB.SubstituteNameLength = slen * sizeof(WCHAR); | 1360 | MRPB.SubstituteNameLength = (slen - 1) * sizeof(WCHAR); |
1357 | MRPB.PrintNameOffset = MRPB.SubstituteNameLength + sizeof(WCHAR); | 1361 | MRPB.PrintNameOffset = MRPB.SubstituteNameLength + sizeof(WCHAR); |
1358 | MRPB.PrintNameLength = plen * sizeof(WCHAR); | 1362 | MRPB.PrintNameLength = (plen - 1) * sizeof(WCHAR); |
1359 | 1363 | ||
1360 | wcscpy(MRPB.PathBuffer, L"\\??\\"); | 1364 | wcscpy(MRPB.PathBuffer, L"\\??\\"); |
1361 | wcscpy(MRPB.PathBuffer + 4, pbuf); | 1365 | wcscpy(MRPB.PathBuffer + 4, pbuf); |
1362 | wcscpy(MRPB.PathBuffer + slen + 1, pbuf); | 1366 | wcscpy(MRPB.PathBuffer + slen, pbuf); |
1363 | return rptr; | 1367 | return rptr; |
1364 | } | 1368 | } |
1365 | 1369 | ||