fix off by one

master
rascul 2 years ago
parent af0989a549
commit 6644ccef49

@ -46,7 +46,7 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
let mut chunks: Vec<Map<String, Value>> = Vec::new();
while raw.len() > 0 {
let chunk: Vec<u8> = raw.drain(0..7).collect();
let chunk: Vec<u8> = raw.drain(0..8).collect();
if chunk.len() != 8 {
return Err("chunk size too small".into());
}
@ -55,7 +55,7 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
if let Ok((delta, size)) = chunk32(&chunk) {
(delta, size)
} else {
let next_chunk: Vec<u8> = raw.drain(0..3).collect();
let next_chunk: Vec<u8> = raw.drain(0..4).collect();
if next_chunk.len() != 4 {
return Err("next_chunk size too small".into());
}
@ -68,7 +68,7 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
}
};
let r = Range { start: 0 as usize, end: (size - 1) as usize };
let r = Range { start: 0 as usize, end: size as usize };
let text_chunk: Vec<u8> = raw.drain(r).collect();
if text_chunk.len() != size as usize {

Loading…
Cancel
Save