Skip to content

Commit

Permalink
GT3X: Harden against unexpected EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Mar 30, 2024
1 parent 29f5e50 commit 213de2a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/actigraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ impl<R: Read> LogRecordIterator<R> {

let mut data = &mut data[0..record_header.record_size as usize + 1];

self.buffer.read_exact(&mut data).unwrap();

Some((record_header, data))
match self.buffer.read_exact(&mut data) {
Ok(_) => Some((record_header, data)),
Err(_) => {
// Todo: Raise proper Python warning so users can catch this
println!("Warning: Unexpected end of file");
None
},
}
}
Err(_) => None,
}
Expand Down

0 comments on commit 213de2a

Please sign in to comment.