Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,25 @@ fn create_dir_all_with_junctions() {
assert!(d.exists());
}

#[test]
#[cfg(windows)]
fn junction_point_overlong_path() {
// Regression test: an `original` path long enough to exceed the inline
// reparse buffer used to be copied past the end of the stack array. It must
// now be rejected with a clean error instead of overflowing.
let tmpdir = tmpdir();
let link = tmpdir.join("junction");

// The `\\?\` prefix bypasses MAX_PATH normalization so the path is copied
// through verbatim. 20_000 code units lands in the old overflow window: it
// passed the previous `> u16::MAX` byte check yet exceeded the buffer.
let mut original = String::from(r"\\?\C:\");
original.push_str(&"a".repeat(20_000));

let err = junction_point(Path::new(&original), &link).unwrap_err();
assert_eq!(err.kind(), ErrorKind::InvalidInput);
}

#[test]
fn metadata_access_times() {
let start_time = SystemTime::now();
Expand Down
Loading