fix: improve if/else with a match case

pull/15/head
EKTehtris 3 years ago
parent 23a29e41a5
commit 144af1f2f3

@ -258,21 +258,23 @@ impl LdSoCache {
) )
)?; )?;
let mut is_old: bool = false; let mut is_old: bool = false;
if header != LD_SO_CACHE_HEADER { match header {
if header != LD_SO_CACHE_HEADER_OLD { LD_SO_CACHE_HEADER => {
return Err(io::Error::new( // we have to reset the position since we found the new header
io::ErrorKind::InvalidData, cursor.set_position(LD_SO_CACHE_HEADER.len() as u64);
"invalid ld.so.cache header", }
)); LD_SO_CACHE_HEADER_OLD => {
} else {
is_old = true; is_old = true;
// add a padding corresponding to LD_SO_CACHE_HEADER_OLD // add a padding corresponding to LD_SO_CACHE_HEADER_OLD
// size 11 + 1 to align on 12 bytes or 3*4 bounds // size 11 + 1 to align on 12 bytes or 3*4 bounds
cursor.consume(1) cursor.consume(1)
} }
} else { _ => {
// we have to reset the position since we found the new header return Err(io::Error::new(
cursor.set_position(LD_SO_CACHE_HEADER.len() as u64); io::ErrorKind::InvalidData,
"invalid ld.so.cache header",
));
}
} }
let num_entries: u32 = read_u32(&mut cursor)?; let num_entries: u32 = read_u32(&mut cursor)?;

Loading…
Cancel
Save