git: d3b9b83623f2 - stable/13 - [fib algo][dxr] Fix undefined behavior.

Marko Zec zec at FreeBSD.org
Sat Sep 18 17:40:02 UTC 2021


The branch stable/13 has been updated by zec:

URL: https://cgit.FreeBSD.org/src/commit/?id=d3b9b83623f2b7ab89d9c09b3e93360e0b72402b

commit d3b9b83623f2b7ab89d9c09b3e93360e0b72402b
Author:     Marko Zec <zec at FreeBSD.org>
AuthorDate: 2021-09-15 20:23:17 +0000
Commit:     Marko Zec <zec at FreeBSD.org>
CommitDate: 2021-09-18 17:36:32 +0000

    [fib algo][dxr] Fix undefined behavior.
    
    The result of shifting uint32_t by 32 (or more) is undefined: fix it.
    
    (cherry picked from commit 442c8a245ee3c6640fc9321e18e8316edf469805)
---
 sys/netinet/in_fib_dxr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c
index ec32819a5a6d..7afe2a3da024 100644
--- a/sys/netinet/in_fib_dxr.c
+++ b/sys/netinet/in_fib_dxr.c
@@ -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;
 


More information about the dev-commits-src-all mailing list