Skip to content

Commit 01a9842

Browse files
committed
fix symlink test on windows
1 parent 1849b41 commit 01a9842

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

library/std/src/sys/fs/windows.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,13 @@ impl Dir {
12221222
unsafe {
12231223
buffer.write(c::REPARSE_DATA_BUFFER {
12241224
ReparseTag: c::IO_REPARSE_TAG_SYMLINK,
1225-
ReparseDataLength: u16::try_from(size_of_val(&sym_buffer)).or(Err(TOO_LONG_ERR))?,
1225+
ReparseDataLength: u16::try_from(
1226+
size_of::<c::REPARSE_DATA_BUFFER>()
1227+
+ size_of::<c::SYMBOLIC_LINK_REPARSE_BUFFER>()
1228+
+ usize::from(file_name_len) * 2
1229+
- offset_of!(c::REPARSE_DATA_BUFFER, Reserved),
1230+
)
1231+
.or(Err(TOO_LONG_ERR))?,
12261232
Reserved: 0,
12271233
rest: (),
12281234
});
@@ -1244,7 +1250,12 @@ impl Dir {
12441250
linkfile.handle.as_raw_handle(),
12451251
c::FSCTL_SET_REPARSE_POINT,
12461252
&raw const buffer as *const c_void,
1247-
u32::try_from(size_of_val(&buffer)).or(Err(TOO_LONG_ERR))?,
1253+
u32::try_from(
1254+
size_of::<c::REPARSE_DATA_BUFFER>()
1255+
+ size_of::<c::SYMBOLIC_LINK_REPARSE_BUFFER>()
1256+
+ usize::from(file_name_len) * 2,
1257+
)
1258+
.or(Err(TOO_LONG_ERR))?,
12481259
ptr::null_mut(),
12491260
0,
12501261
ptr::null_mut(),

0 commit comments

Comments
 (0)