Prevent reading past TES4 record in header parse

Bump version to 0.1.3
This commit is contained in:
Tyler Hallada 2021-06-12 22:54:10 -04:00
parent c952eeac7a
commit 12beff1014
3 changed files with 8 additions and 5 deletions

2
Cargo.lock generated
View File

@ -232,7 +232,7 @@ dependencies = [
[[package]] [[package]]
name = "skyrim-cell-dump" name = "skyrim-cell-dump"
version = "0.1.2" version = "0.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argh", "argh",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "skyrim-cell-dump" name = "skyrim-cell-dump"
version = "0.1.2" version = "0.1.3"
edition = "2018" edition = "2018"
authors = ["Tyler Hallada <tyler@hallada.net>"] authors = ["Tyler Hallada <tyler@hallada.net>"]
description = "Library and binary for parsing Skyrim plugin files and extracting CELL data" description = "Library and binary for parsing Skyrim plugin files and extracting CELL data"

View File

@ -263,12 +263,14 @@ fn parse_group_data<'a>(
} }
fn parse_plugin_header(input: &[u8]) -> IResult<&[u8], PluginHeader> { fn parse_plugin_header(input: &[u8]) -> IResult<&[u8], PluginHeader> {
let (mut input, _tes4) = verify(parse_record_header, |record_header| { let (mut input, tes4) = verify(parse_record_header, |record_header| {
record_header.record_type == "TES4" record_header.record_type == "TES4"
})(input)?; })(input)?;
let (remaining, _hedr) = verify(parse_field_header, |field_header| { let mut consumed_bytes = 0;
let (remaining, hedr) = verify(parse_field_header, |field_header| {
field_header.field_type == "HEDR" field_header.field_type == "HEDR"
})(input)?; })(input)?;
consumed_bytes += hedr.size as u32 + 6;
input = remaining; input = remaining;
let (remaining, (version, num_records_and_groups, next_object_id)) = parse_hedr_fields(input)?; let (remaining, (version, num_records_and_groups, next_object_id)) = parse_hedr_fields(input)?;
input = remaining; input = remaining;
@ -276,8 +278,9 @@ fn parse_plugin_header(input: &[u8]) -> IResult<&[u8], PluginHeader> {
let mut description = None; let mut description = None;
let mut masters = vec![]; let mut masters = vec![];
let mut large_size = None; let mut large_size = None;
loop { while consumed_bytes < tes4.size as u32 {
let (remaining, field) = parse_field_header(input)?; let (remaining, field) = parse_field_header(input)?;
consumed_bytes += field.size as u32 + 6;
input = remaining; input = remaining;
match field.field_type { match field.field_type {
"CNAM" => { "CNAM" => {