From 796eb67df268b30f7787a8bb54cd1d45ce5e0bb3 Mon Sep 17 00:00:00 2001 From: kevin9327 Date: Wed, 9 Sep 2026 13:24:52 +0900 Subject: [PATCH] fix(core): compare relative paths longer than 512 bytes --- crates/fff-core/src/simd_path.rs | 23 +++++++++++++++++++++++ crates/fff-core/src/types.rs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/fff-core/src/simd_path.rs b/crates/fff-core/src/simd_path.rs index 0795e042e..0f5894401 100644 --- a/crates/fff-core/src/simd_path.rs +++ b/crates/fff-core/src/simd_path.rs @@ -526,6 +526,29 @@ mod tests { assert_eq!(std::str::from_utf8(&reconstructed).unwrap(), path); } + #[test] + fn test_relative_path_eq_path_exceeding_512_bytes() { + let mut path = String::new(); + while path.len() < 600 { + path.push_str("deeply_nested_directory_segment/"); + } + path.push_str("needle_file.rs"); + assert!(path.len() > 512 && path.len() < PATH_BUF_SIZE); + + let (store, _strings, files) = build_test_store(&[path.as_str(), "src/lib.rs"]); + let arena = store.as_arena_ptr(); + + assert!( + files[0].relative_path_eq(arena, &path), + "a PATH_MAX-legal path must compare equal to itself" + ); + + // Short paths keep comparing exactly as before. + assert!(files[1].relative_path_eq(arena, "src/lib.rs")); + assert!(!files[1].relative_path_eq(arena, "src/main.rs")); + assert!(!files[0].relative_path_eq(arena, &path[..path.len() - 1])); + } + #[test] fn test_filename_cow_mid_chunk() { let (store, strings, _files) = build_test_store(&["src/components/Button.tsx"]); diff --git a/crates/fff-core/src/types.rs b/crates/fff-core/src/types.rs index 72661c967..7b33dc56e 100644 --- a/crates/fff-core/src/types.rs +++ b/crates/fff-core/src/types.rs @@ -372,7 +372,7 @@ impl FileItem { if other.len() != self.path.byte_len as usize { return false; } - let mut buf = [0u8; 512]; + let mut buf = [0u8; PATH_BUF_SIZE]; let mine = self.path.read_to_buf(arena, &mut buf); mine == other }