fix: audit fixes for 4 medium-severity bugs: index_cache tail hash, read_cache doc, mutex poison recovery, Remove event handling
This commit is contained in:
@@ -86,11 +86,12 @@ fn compute_file_hash(file_path: &Path) -> std::io::Result<u64> {
|
||||
let mut tf = std::io::BufReader::new(file);
|
||||
tf.read_exact(&mut tail)?;
|
||||
} else {
|
||||
// File is small enough that head already covers everything;
|
||||
// tail overlaps with head — just take the last tail_size bytes
|
||||
let start = head.len().saturating_sub(tail_size);
|
||||
tail = head[start..].to_vec();
|
||||
tail.resize(tail_size, 0);
|
||||
// File fits within head+tail window. Seek to read the real tail
|
||||
// for correctness — approximating from head misses bytes beyond head_size.
|
||||
let tail_start = file_size.saturating_sub(tail_size as u64);
|
||||
let mut file = std::fs::File::open(file_path)?;
|
||||
std::io::Seek::seek(&mut file, std::io::SeekFrom::Start(tail_start))?;
|
||||
file.read_exact(&mut tail)?;
|
||||
}
|
||||
|
||||
let mut hasher_state = xxhash_rust::xxh3::Xxh3::new();
|
||||
@@ -242,4 +243,4 @@ mod tests {
|
||||
|
||||
assert_ne!(h1, h2, "hash should change when content changes");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user