sndjvu / workspace

monorepo for SnDjVu's Rust code, website, etc.
https://www.sndjvu.org
Apache License 2.0
6 stars 1 forks source link

Integer arithmetic/casting audit #20

Open cole-miller opened 2 years ago

cole-miller commented 2 years ago

I've eliminated unchecked integer arithmetic from sndjvu_format::ser, except for a few innocuous uses: https://github.com/sndjvu/workspace/blob/eecf635735e64acb439e1da28954596a1a1ea30d/crates/sndjvu_format/src/ser.rs#L7

This is important because most of the arithmetic in that module goes to calculating values for various length/offset fields in the transfer format, and if one of those calculations overflows we want to signal an error rather than serialize a broken document.