Skip to content

Commit

Permalink
Revert "Merge pull request #15 from Holzhaus/length-checks"
Browse files Browse the repository at this point in the history
This reverts commit 2711f48, reversing
changes made to 1464384.
  • Loading branch information
Holzhaus committed Feb 18, 2022
1 parent 2711f48 commit 1526e50
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions src/anlz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,15 +1095,6 @@ impl Content {

fn parse_waveform_detail<'a>(input: &'a [u8], header: &Header) -> IResult<&'a [u8], Self> {
let (input, len_entry_bytes) = nom::number::complete::be_u32(input)?;
// All waveform detail entries should be 1 byte long. If we see other values here,
// some reverse-engineering is needed.
if len_entry_bytes != 2 {
return Err(Err::Error(nom::error::Error::from_error_kind(
input,
ErrorKind::LengthValue,
)));
}

let (input, len_entries) = nom::number::complete::be_u32(input)?;
let (input, unknown) = nom::number::complete::be_u32(input)?;
let (input, content_data_slice) = nom::bytes::complete::take(header.content_size())(input)?;
Expand All @@ -1129,15 +1120,6 @@ impl Content {
_header: &Header,
) -> IResult<&'a [u8], Self> {
let (input, len_entry_bytes) = nom::number::complete::be_u32(input)?;
// All waveform color preview entries should be 6 bytes long. If we see other values here,
// some reverse-engineering is needed.
if len_entry_bytes != 2 {
return Err(Err::Error(nom::error::Error::from_error_kind(
input,
ErrorKind::LengthValue,
)));
}

let (input, len_entries) = nom::number::complete::be_u32(input)?;
let entry_count = usize::try_from(len_entries)
.map_err(|_| nom_input_error_with_kind(input, ErrorKind::TooLarge))?;
Expand All @@ -1162,15 +1144,6 @@ impl Content {
_header: &Header,
) -> IResult<&'a [u8], Self> {
let (input, len_entry_bytes) = nom::number::complete::be_u32(input)?;
// All waveform color detail entries should be 2 bytes long. If we see other values here,
// some reverse-engineering is needed.
if len_entry_bytes != 2 {
return Err(Err::Error(nom::error::Error::from_error_kind(
input,
ErrorKind::LengthValue,
)));
}

let (input, len_entries) = nom::number::complete::be_u32(input)?;
let entry_count = usize::try_from(len_entries)
.map_err(|_| nom_input_error_with_kind(input, ErrorKind::TooLarge))?;
Expand All @@ -1192,15 +1165,6 @@ impl Content {

fn parse_song_structure<'a>(input: &'a [u8], _header: &Header) -> IResult<&'a [u8], Self> {
let (input, len_entry_bytes) = nom::number::complete::be_u32(input)?;
// All phrase entries should be 24 bytes long. If we see other values here, some
// reverse-engineering is needed.
if len_entry_bytes != 24 {
return Err(Err::Error(nom::error::Error::from_error_kind(
input,
ErrorKind::LengthValue,
)));
}

let (input, len_entries) = nom::number::complete::be_u16(input)?;
let entry_count = usize::try_from(len_entries)
.map_err(|_| nom_input_error_with_kind(input, ErrorKind::TooLarge))?;
Expand Down

0 comments on commit 1526e50

Please sign in to comment.