Skip to content

Commit

Permalink
[fib algo][dxr] Fix undefined behavior.
Browse files Browse the repository at this point in the history
The result of shifting uint32_t by 32 (or more) is undefined: fix it.

(cherry picked from commit 442c8a2)
  • Loading branch information
gornjas committed Sep 18, 2021
1 parent 5f4ba94 commit d3b9b83
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sys/netinet/in_fib_dxr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,10 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q,
#endif
plen = q->entries[ui].plen;
ip = ntohl(q->entries[ui].addr4.s_addr);
hmask = 0xffffffffU >> plen;
if (plen < 32)
hmask = 0xffffffffU >> plen;
else
hmask = 0;
start = (ip & ~hmask) >> DXR_RANGE_SHIFT;
end = (ip | hmask) >> DXR_RANGE_SHIFT;

Expand Down

0 comments on commit d3b9b83

Please sign in to comment.