Commit b7fe0b6
authored
Strengthen undefined behavior prevention in checkSignedBitfieldOverflow (#2418)
This one was found by
[afl++](https://github.com/AFLplusplus/AFLplusplus). Executing `bitfield
0 set i64 0 1` triggers UBSan at the `int64_t minincr = min - value;`
calculation. To fix the undefined behavior in the `minincr` calculation
and strengthen the protection in the `maxincr` calculation, we cast
both, the minuend and the subtrahend, to an unsigned int, do the
calculation, and then cast the result back into a signed int.
Signed-off-by: Fusl <[email protected]>1 parent 52b5519 commit b7fe0b6
1 file changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
500 | 498 | | |
501 | 499 | | |
502 | 500 | | |
| |||
0 commit comments