Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace custom u16 le parser with existent rust method #450

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl GzHeaderParser {
if let Some(crc) = crc {
crc.update(buffer);
}
let xlen = parse_le_u16(&buffer);
let xlen = parse_le_u16(buffer);
self.header.extra = Some(vec![0; xlen as usize]);
self.state = GzHeaderState::Extra(crc.take(), 0);
} else {
Expand Down Expand Up @@ -209,7 +209,7 @@ impl GzHeaderParser {
while (*count as usize) < buffer.len() {
*count += read_into(r, &mut buffer[*count as usize..])? as u8;
}
let stored_crc = parse_le_u16(&buffer);
let stored_crc = parse_le_u16(buffer);
let calced_crc = crc.sum() as u16;
if stored_crc != calced_crc {
return Err(corrupt());
Expand Down Expand Up @@ -277,7 +277,7 @@ fn read_to_nul<R: Read>(r: &mut R, buffer: &mut Vec<u8>) -> Result<()> {
}

fn parse_le_u16(buffer: &[u8; 2]) -> u16 {
(buffer[0] as u16) | ((buffer[1] as u16) << 8)
u16::from_le_bytes(*buffer)
}

fn bad_header() -> Error {
Expand Down
Loading