Skip to content

Commit

Permalink
archive: fix subtract with overflow for header.size
Browse files Browse the repository at this point in the history
  • Loading branch information
anfedotoff authored Sep 17, 2022
1 parent e2b5207 commit 6fdaffd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/archive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ impl<'a> Member<'a> {
)?;

// adjust the offset and size accordingly
*offset = header_offset + SIZEOF_HEADER + len;
header.size -= len;
if header.size > len {
*offset = header_offset + SIZEOF_HEADER + len;
header.size -= len;

// the name may have trailing NULs which we don't really want to keep
Some(name.trim_end_matches('\0'))
// the name may have trailing NULs which we don't really want to keep
Some(name.trim_end_matches('\0'))
} else {
None
}
} else {
None
};
Expand Down

0 comments on commit 6fdaffd

Please sign in to comment.