Date: Wed, 15 Sep 2021 20:50:09 GMT From: Marko Zec <zec@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 442c8a245ee3 - main - [fib algo][dxr] Fix undefined behavior. Message-ID: <202109152050.18FKo9Xq062152@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=442c8a245ee3c6640fc9321e18e8316edf469805 commit 442c8a245ee3c6640fc9321e18e8316edf469805 Author: Marko Zec <zec@FreeBSD.org> AuthorDate: 2021-09-15 20:23:17 +0000 Commit: Marko Zec <zec@FreeBSD.org> CommitDate: 2021-09-15 20:42:48 +0000 [fib algo][dxr] Fix undefined behavior. The result of shifting uint32_t by 32 (or more) is undefined: fix it. --- 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109152050.18FKo9Xq062152>