[PATCH] Core: fix conversion of IPv4-mapped IPv6 addresses

Piotr Sikora piotr at aviatrix.com
Thu Mar 21 06:53:54 UTC 2024


Hi Sergey,

> The "shift" remark doesn't describe a problem in details.

It's not a remark, it's the name of the UndefinedBehaviorSanitizer
check that caught the issue [1].

> @@ -507,7 +507,7 @@ ngx_cidr_match(struct sockaddr *sa, ngx_
> 
>              p = inaddr6->s6_addr;
> 
> -            inaddr = p[12] << 24;
> +            inaddr = (in_addr_t) p[12] << 24;
>              inaddr += p[13] << 16;
>              inaddr += p[14] << 8;
>              inaddr += p[15];

While this minimizes the diff and silences the error at hand,
I find my version more readable.

But you're obviously welcome to commit either version.

[1] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Best regards,
Piotr Sikora


More information about the nginx-devel mailing list