Commit e31c44a
committed
defrag: drop unsigned underflow in RB_NFIND search key
The seek into the fragment tree used frag_offset - 1 as the key
for RB_NFIND. For the first fragment of an IP datagram frag_offset
is 0 and the uint16_t subtraction wraps to 65535. The wrap is
harmless in practice because no fragment can have offset 65535
(IPv4 limits the field to 8191 << 3 = 65528, and IPv6 follows the
same alignment), so RB_NFIND returns NULL and the existing RB_MIN
fallback walks the tree forward to reach the same end state. The
path is reached by accident though, and fuzzer integer overflow
sanitizers flag the wrap.
Guard the RB_NFIND call with if (frag_offset > 0) so the
subtraction never runs on a zero offset. The frag_offset == 0 case
leaves next at NULL and falls into the existing RB_MIN fallback,
which matches the prior end state on every input. The 35 defrag
unit tests pass unchanged.
Bug: #8232.1 parent 367ca7f commit e31c44a
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
660 | 665 | | |
661 | 666 | | |
662 | 667 | | |
| |||
0 commit comments