[PATCH V2] Route: avoided undefined behaviour.

pubg lover imranrazair142 at gmail.com
Thu Jun 23 23:38:06 UTC 2022


Hindi language please

On Fri, Jun 24, 2022, 12:40 AM Andrew Clayton <andrew at digital-domain.net>
wrote:

> 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.
> ---
> V2 Changes
>
>   * Promote the shiftee to ULL rather than just UL
>
>  src/nxt_http_route_addr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/nxt_http_route_addr.c b/src/nxt_http_route_addr.c
> index 2907a90..985fb73 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)) {
> --
> 2.36.1
>
> _______________________________________________
> unit mailing list -- unit at nginx.org
> To unsubscribe send an email to unit-leave at nginx.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/unit/attachments/20220624/64701371/attachment.htm>


More information about the unit mailing list