Commit 23b0e1f
authored
rust: fix int underflow when chunk wasn't closed (#1480)
### Changelog
<!-- Write a one-sentence summary of the user-impacting change (API,
UI/UX, performance, etc) that could appear in a changelog. Write "None"
if there is no user-facing change -->
- rust: fix int underflow on chunk with invalid size
### Docs
<!-- Link to a Docs PR, tracking ticket in Linear, OR write "None" if no
documentation changes are needed. -->
None
### Description
When a chunk doesn't close correctly (loss of power, crash, etc.) the
size that was written will be `u64::MAX`. If you try and read a file
like this with the Rust reader it breaks because the size of the chunk
is expected to be valid. In debug mode this will panic due to underflow,
in release mode this value will wrap and break something else down the
track.
This change explicitly uses checked calculations for the chunk size and
returns an `UnexpectedEoc` error if any of the calculations overflow.
Fixes #1479.
Fixes FIRE-202.1 parent f5a53e9 commit 23b0e1f
File tree
2 files changed
+40
-1
lines changed- rust
- src/sans_io
- tests/data
2 files changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
512 | 517 | | |
513 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
514 | 521 | | |
515 | 522 | | |
516 | 523 | | |
| |||
706 | 713 | | |
707 | 714 | | |
708 | 715 | | |
| 716 | + | |
709 | 717 | | |
710 | 718 | | |
711 | 719 | | |
| |||
985 | 993 | | |
986 | 994 | | |
987 | 995 | | |
| 996 | + | |
988 | 997 | | |
989 | 998 | | |
990 | 999 | | |
| |||
1206 | 1215 | | |
1207 | 1216 | | |
1208 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
1209 | 1245 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments