From 3363bd836accb9d9b8a1bac837de9c0d2d862e35 Mon Sep 17 00:00:00 2001 From: wcampbell Date: Wed, 2 Aug 2023 20:33:17 -0400 Subject: [PATCH] backhand: Increase DirectoryIndex::name_size length --- CHANGELOG.md | 1 + src/dir.rs | 2 +- src/reader.rs | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc872e3..d7314cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug Fix - When creating an empty image using `FilesystemWriter::default()`, correctly create the ID table for UID and GID entries. Reported: ([@hwittenborn](https://github.com/hwittenborn)) ([!250](https://github.com/wcampbell0x2a/backhand/issues/275)), Fixed: ([#275](https://github.com/wcampbell0x2a/backhand/pull/275)) - Remove manual `Clone` impl for `FilesystemReaderFile` ([#277](https://github.com/wcampbell0x2a/backhand/pull/277)) +- Increase `DirectoryIndex::name_size` length from 100 to 255. ([@eatradish](https://github.com/eatradish)) ([!282](https://github.com/wcampbell0x2a/backhand/issues/282)), Fixed: ([#283](https://github.com/wcampbell0x2a/backhand/pull/283)) ## Security - Only allow root and simple filenames into `DirEntry`([@rbran](https://github.com/rbran)) ([#271](https://github.com/wcampbell0x2a/backhand/pull/271)) diff --git a/src/dir.rs b/src/dir.rs index 8f16890e..48f296c9 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -102,7 +102,7 @@ pub struct DirectoryIndex { pub(crate) index: u32, /// Start offset of a directory table metadata block, relative to the directory table start. pub(crate) start: u32, - #[deku(assert = "*name_size < 100")] + #[deku(assert = "*name_size < 256")] pub(crate) name_size: u32, #[deku(count = "*name_size + 1")] pub(crate) name: Vec, diff --git a/src/reader.rs b/src/reader.rs index 9576d2dc..9d13187a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -134,9 +134,14 @@ pub trait SquashFsReader: BufReadSeek { ret_vec.insert(inode.header.inode_number, inode); input_bits = rest; } - Err(_) => { - // try next block, inodes can span multiple blocks! - break; + Err(e) => { + if let DekuError::Incomplete(_) = e { + // try next block, inodes can span multiple blocks! + break; + } else { + error!("{e}"); + return Err(BackhandError::Deku(e)); + } } } }