Skip to content

Commit

Permalink
Merge 3ea4ca5 into c4ba053
Browse files Browse the repository at this point in the history
  • Loading branch information
wcampbell0x2a authored Dec 1, 2024
2 parents c4ba053 + 3ea4ca5 commit de482c4
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 106 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `x86_64-pc-windows-gnu` support ([@Wolfyxon](https://github.com/Wolfyxon)) ([#634](https://github.com/wcampbell0x2a/backhand/pull/634))
- Add [zlib-rs](https://github.com/trifectatechfoundation/zlib-rs) support through `--feature gzip-zlib-rs`.

#### Security
- Prevent self referential dirs, which could cause a stack overflow ([#624](https://github.com/wcampbell0x2a/backhand/pull/495))
- Avoid high allocations for high inode count ([#624](https://github.com/wcampbell0x2a/backhand/pull/495))

### `backhand-cli`
- Add `--no-compression-options` to `add` and `replace` to remove compression options from image after modification.
- Add `--pad-len` to `replace` and `add` to control the length of end-of-image padding ([#604](https://github.com/wcampbell0x2a/backhand/pull/604))
Expand Down
3 changes: 2 additions & 1 deletion backhand/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ pub trait SquashFsReader: BufReadSeek + Sized {
)?;

let mut inodes = IntMap::default();
inodes.try_reserve(superblock.inode_count as usize)?;
// Be nice the allocator, and only allocate a max of u16::MAX count of Indoes
inodes.try_reserve(superblock.inode_count.min(u16::MAX as u32) as usize)?;

let byte_len = bytes.len();
let mut cursor = Cursor::new(bytes);
Expand Down
6 changes: 6 additions & 0 deletions backhand/src/squashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ impl<'b> Squashfs<'b> {
// BasicDirectory, ExtendedDirectory
InodeId::BasicDirectory | InodeId::ExtendedDirectory => {
// its a dir, extract all children inodes
if *found_inode == dir_inode {
error!("self referential dir to already read inode");
return Err(BackhandError::UnexpectedInode(
dir_inode.inner.clone(),
));
}
self.extract_dir(fullpath, root, found_inode, &self.id)?;
InnerNode::Dir(SquashfsDir::default())
}
Expand Down
Loading

0 comments on commit de482c4

Please sign in to comment.