Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe40854

Browse files
Merge pull request #495 from wcampbell0x2a/use-libafl-fuzzer-as-libfuzzer
2 parents 155bbc9 + 82ca4d3 commit fe40854

6 files changed

Lines changed: 185 additions & 106 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Add `x86_64-pc-windows-gnu` support ([@Wolfyxon](https://github.com/Wolfyxon)) ([#634](https://github.com/wcampbell0x2a/backhand/pull/634))
2020
- Add [zlib-rs](https://github.com/trifectatechfoundation/zlib-rs) support through `--feature gzip-zlib-rs`.
2121

22+
#### Security
23+
- Prevent self referential dirs, which could cause a stack overflow ([#624](https://github.com/wcampbell0x2a/backhand/pull/495))
24+
- Avoid high allocations for high inode count ([#624](https://github.com/wcampbell0x2a/backhand/pull/495))
25+
2226
### `backhand-cli`
2327
- Add `--no-compression-options` to `add` and `replace` to remove compression options from image after modification.
2428
- Add `--pad-len` to `replace` and `add` to control the length of end-of-image padding ([#604](https://github.com/wcampbell0x2a/backhand/pull/604))

backhand/src/reader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ pub trait SquashFsReader: BufReadSeek + Sized {
9595
)?;
9696

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

100101
let byte_len = bytes.len();
101102
let mut cursor = Cursor::new(bytes);

backhand/src/squashfs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ impl<'b> Squashfs<'b> {
533533
// BasicDirectory, ExtendedDirectory
534534
InodeId::BasicDirectory | InodeId::ExtendedDirectory => {
535535
// its a dir, extract all children inodes
536+
if *found_inode == dir_inode {
537+
error!("self referential dir to already read inode");
538+
return Err(BackhandError::UnexpectedInode(
539+
dir_inode.inner.clone(),
540+
));
541+
}
536542
self.extract_dir(fullpath, root, found_inode, &self.id)?;
537543
InnerNode::Dir(SquashfsDir::default())
538544
}

0 commit comments

Comments
 (0)