diff options
| author | rorka <rorka@rorka.my.domain> | 2026-06-23 20:38:02 +0300 |
|---|---|---|
| committer | rorka <rorka@rorka.my.domain> | 2026-06-23 20:38:02 +0300 |
| commit | 3c2bec16cf37437759004bdf240fa6c85bc9e428 (patch) | |
| tree | 42c760a8dcd878cfee91c41958874c23b8bc7889 /src/check.rs | |
| parent | f726a6920d85f149efeae9ca1624138e9e374938 (diff) | |
| download | ror-3c2bec16cf37437759004bdf240fa6c85bc9e428.tar.gz ror-3c2bec16cf37437759004bdf240fa6c85bc9e428.zip | |
refactor: optimize package extraction and harden path traversal protection
Diffstat (limited to 'src/check.rs')
| -rwxr-xr-x[-rw-r--r--] | src/check.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/check.rs b/src/check.rs index 9e9b775..530814f 100644..100755 --- a/src/check.rs +++ b/src/check.rs @@ -24,13 +24,18 @@ fn load_expected_hashes( binary: &BinaryPackage, cfg: &Config, ) -> Result<HashMap<String, String>, String> { + let effective_filename = crate::install::resolve_filename( + &crate::install::load_package(_pkg_name).unwrap(), + binary, + ); + let urls = if !binary.url.is_empty() { vec![binary.url.clone()] } else { binary .mirrors .iter() - .map(|m| m.replace("{filename}", &binary.filename)) + .map(|m| m.replace("{filename}", &effective_filename)) .collect() }; @@ -50,7 +55,7 @@ fn load_expected_hashes( .as_ref() .ok_or_else(|| "Missing dict URL for .ror".to_string())?; let dict_path = download_and_verify(dict_url, "", cfg)?; - let res = extract_ror(&archive_path, &dict_path, work_dir); + let res = extract_ror(&archive_path, work_dir); let _ = fs::remove_file(&dict_path); res } else if pkg_type == "sror" { @@ -106,7 +111,7 @@ pub fn check_integrity(cfg: &Config) { } }; - let binary = match select_binary_for_arch(&pkg, &cfg.global.arch, &cfg.global.libc) { + let binary = match select_binary_for_arch(&pkg, &cfg.global.arch, &cfg.global.libc, None) { Ok(b) => b, Err(_) => { println!("{}", "SKIP (no binary)".yellow()); @@ -196,3 +201,4 @@ pub fn check_integrity(cfg: &Config) { } } } + |