Skip to content

Commit 4874451

Browse files
committed
fix: Rewind file pointer when reading hashed ROM
1 parent 26ea69d commit 4874451

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

support/src/encode_format.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
fs::{self, File},
3-
io::{self, Read},
3+
io::{self, Read, Seek},
44
path::{Path, PathBuf},
55
};
66

@@ -103,6 +103,9 @@ fn find_rom_by_hash(target_hash: &String, asset_dir: &Path) -> Result<Vec<u8>, S
103103

104104
if &hash == target_hash {
105105
let mut buffer = Vec::new();
106+
if let Err(_) = file.seek(io::SeekFrom::Start(0)) {
107+
return Err("Could not reread from file after hash check".into());
108+
}
106109
if let Err(_) = file.read_to_end(&mut buffer) {
107110
return Err(format!("Could not open SHA matched ROM {:?}", entry.path()));
108111
}

0 commit comments

Comments
 (0)