Commit 2167247
committed
fix: handle overflow when computing mmap offset during restore
Since we dropped the explicit offset field from the snapshot file, we
are implicit computing it as "sum of sizes of all preceding regions". If
the snapshot file is corrupted, it can describe regions whose sum
exceeds u64::MAX. Fix this by adding overflow checks and returning an
error in case of overflows
We also error out if it exceeds i64::MAX as the offset argument to
mmap(2) is a signed 64 bit integer value.
Fixes: d835805
Signed-off-by: Patrick Roy <[email protected]>1 parent 07ce762 commit 2167247
1 file changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
191 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
| |||
0 commit comments