summaryrefslogtreecommitdiffstats
path: root/src/launcher/extract.rs
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-18 23:47:48 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-18 23:47:48 -0600
commitcd8bf1667494070c3a22ab5d63b559a9742b8a1a (patch)
tree6f93f0c0fbdccfa18733499845a8bc7c298c402f /src/launcher/extract.rs
parentbuilding classpath (diff)
more stuff
Diffstat (limited to 'src/launcher/extract.rs')
-rw-r--r--src/launcher/extract.rs26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/launcher/extract.rs b/src/launcher/extract.rs
index 206d34f..0a08175 100644
--- a/src/launcher/extract.rs
+++ b/src/launcher/extract.rs
@@ -7,6 +7,7 @@ use std::path::{Component, Path, PathBuf};
use log::{debug, trace};
use zip::result::ZipError;
use zip::ZipArchive;
+use crate::util;
#[derive(Debug)]
pub enum ZipExtractError {
@@ -48,27 +49,10 @@ impl Error for ZipExtractError {
}
fn check_entry_path(name: &str) -> Result<&Path, ZipExtractError> {
- let entry_path: &Path = Path::new(name);
-
- let mut depth = 0usize;
- for component in entry_path.components() {
- depth = match component {
- Component::Prefix(_) | Component::RootDir =>
- return Err(ZipExtractError::InvalidEntry {
- why: "root path component in entry",
- name: name.to_owned()
- }),
- Component::ParentDir => depth.checked_sub(1)
- .map_or_else(|| Err(ZipExtractError::InvalidEntry {
- why: "entry path escapes extraction root",
- name: name.to_owned()
- }), |s| Ok(s))?,
- Component::Normal(_) => depth + 1,
- _ => depth
- }
- }
-
- Ok(entry_path)
+ util::check_path(name).map_err(|e| ZipExtractError::InvalidEntry {
+ why: e,
+ name: name.to_owned()
+ })
}
#[cfg(unix)]