Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit e6972c7

Browse files
add comments
1 parent 590e84c commit e6972c7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runtime/src/hardened_unpack.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,17 @@ fn sanitize_path(entry_path: &Path, dst: &Path) -> Result<Option<PathBuf>> {
246246
};
247247

248248
fs::create_dir_all(parent)?;
249+
250+
// Here we are different than untar_in. The code for tar::unpack_in internally calling unpack is a little different.
251+
// ignore return value here
249252
validate_inside_dst(dst, parent)?;
250253
let target = parent.join(entry_path.file_name().unwrap());
251254

252255
Ok(Some(target))
253256
}
254257

258+
// copied from:
259+
// https://github.com/alexcrichton/tar-rs/blob/d90a02f582c03dfa0fd11c78d608d0974625ae5d/src/entry.rs#L781
255260
fn validate_inside_dst(dst: &Path, file_dst: &Path) -> Result<PathBuf> {
256261
// Abort if target (canonical) parent is outside of `dst`
257262
let canon_parent = file_dst.canonicalize().map_err(|err| {

0 commit comments

Comments
 (0)