mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
fix(archive): handle invalid UTF-8 passwords in 7z decompression
This commit is contained in:
parent
67ca183a25
commit
08ab63837e
@ -194,16 +194,24 @@ pub fn list_archive(
|
|||||||
Ok(true)
|
Ok(true)
|
||||||
};
|
};
|
||||||
|
|
||||||
match password {
|
let result = match password {
|
||||||
Some(password) => {
|
Some(password) => {
|
||||||
|
let password = match password.to_str() {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(_) => return vec![Err(Error::InvalidPassword("7z requires that all passwords are valid UTF-8"))].into_iter(),
|
||||||
|
};
|
||||||
sevenz_rust::decompress_with_extract_fn_and_password(
|
sevenz_rust::decompress_with_extract_fn_and_password(
|
||||||
reader,
|
reader,
|
||||||
".",
|
".",
|
||||||
sevenz_rust::Password::from(password.to_str().unwrap()),
|
sevenz_rust::Password::from(password),
|
||||||
entry_extract_fn,
|
entry_extract_fn,
|
||||||
).unwrap()
|
)
|
||||||
},
|
},
|
||||||
None => sevenz_rust::decompress_with_extract_fn(reader, ".", entry_extract_fn).unwrap(),
|
None => sevenz_rust::decompress_with_extract_fn(reader, ".", entry_extract_fn),
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = result {
|
||||||
|
return vec![Err(e.into())].into_iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
files.into_iter()
|
files.into_iter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user