win,fs: match trailing slash presence in junctions to user input (#4590)

Refs: #4582
This commit is contained in:
Jameson Nash 2024-10-18 15:01:07 -04:00 committed by GitHub
parent 7e6590f31d
commit 058c49b7ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2566,15 +2566,17 @@ static void fs__create_junction(uv_fs_t* req, const WCHAR* path,
path_buf[path_buf_len++] = path[i];
}
if (add_slash)
path_buf[path_buf_len++] = L'\\';
len = path_buf_len - start;
/* Insert null terminator */
path_buf[path_buf_len++] = L'\0';
/* Set the info about the substitute name */
buffer->MountPointReparseBuffer.SubstituteNameOffset = start * sizeof(WCHAR);
buffer->MountPointReparseBuffer.SubstituteNameLength = len * sizeof(WCHAR);
/* Insert null terminator */
path_buf[path_buf_len++] = L'\0';
/* Copy the print name of the target path */
start = path_buf_len;
add_slash = 0;
@ -2592,18 +2594,18 @@ static void fs__create_junction(uv_fs_t* req, const WCHAR* path,
path_buf[path_buf_len++] = path[i];
}
len = path_buf_len - start;
if (len == 2) {
if (len == 2 || add_slash) {
path_buf[path_buf_len++] = L'\\';
len++;
}
/* Insert another null terminator */
path_buf[path_buf_len++] = L'\0';
/* Set the info about the print name */
buffer->MountPointReparseBuffer.PrintNameOffset = start * sizeof(WCHAR);
buffer->MountPointReparseBuffer.PrintNameLength = len * sizeof(WCHAR);
/* Insert another null terminator */
path_buf[path_buf_len++] = L'\0';
/* Calculate how much buffer space was actually used */
used_buf_size = FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) +
path_buf_len * sizeof(WCHAR);