summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_route_addr.c
diff options
context:
space:
mode:
authorAndrew Clayton <andrew@digital-domain.net>2022-06-15 16:20:01 +0100
committerAndrew Clayton <andrew@digital-domain.net>2022-07-21 00:37:20 +0100
commitc1cea3c97d5dfc260a54cab67b7dc1637a3deb59 (patch)
treedcc699a083e9c8a9e7ed56f5d11d6c1b13943d3c /src/nxt_http_route_addr.c
parent02659b1ee3b041d1f4046ac440ea6755455230a1 (diff)
downloadunit-c1cea3c97d5dfc260a54cab67b7dc1637a3deb59.tar.gz
unit-c1cea3c97d5dfc260a54cab67b7dc1637a3deb59.tar.bz2
Router: avoided undefined behaviour.
In src/nxt_http_route_addr.c::nxt_http_route_addr_pattern_parse() there was potentially undefined behaviour when shifting a 32 bit value by 32 bits, this could happen if cidr_prefix was 0. Promote the shiftee to unsigned long long to avoid this issue.
Diffstat (limited to 'src/nxt_http_route_addr.c')
-rw-r--r--src/nxt_http_route_addr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nxt_http_route_addr.c b/src/nxt_http_route_addr.c
index 2907a902..985fb737 100644
--- a/src/nxt_http_route_addr.c
+++ b/src/nxt_http_route_addr.c
@@ -233,7 +233,7 @@ nxt_http_route_addr_pattern_parse(nxt_mp_t *mp,
}
addr.length = delim - addr.start;
- inet->end = htonl(0xFFFFFFFF & (0xFFFFFFFF << (32 - cidr_prefix)));
+ inet->end = htonl(0xFFFFFFFF & (0xFFFFFFFFULL << (32 - cidr_prefix)));
inet->start = nxt_inet_addr(addr.start, addr.length) & inet->end;
if (nxt_slow_path(inet->start == INADDR_NONE)) {