Commit 96baffe
committed
cache: harden integer types and negative-len guard in Cache_read
- Change expected_segbc in Meta_write from long to off_t to prevent
silent truncation on 32-bit/Windows before the INT_MAX cap check.
- Use a size_t intermediate variable (calculated_segbc) in Cache_create
before assigning to cf->segbc to avoid 32-bit long overflow during
the division of content_length / blksz.
- Add a len < 0 guard in Cache_read before the (size_t)len cast to
prevent negative values wrapping to a large unsigned number and
bypassing the remaining-bytes clamp.1 parent f911f7c commit 96baffe
1 file changed
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
869 | | - | |
870 | | - | |
| 869 | + | |
| 870 | + | |
871 | 871 | | |
872 | | - | |
873 | | - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
874 | 877 | | |
875 | 878 | | |
876 | 879 | | |
| |||
1467 | 1470 | | |
1468 | 1471 | | |
1469 | 1472 | | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1470 | 1479 | | |
1471 | 1480 | | |
1472 | 1481 | | |
| |||
0 commit comments