On Thu, 11 Jan 2024 16:14:39 GMT, Joachim Kern <[email protected]> wrote:
>> In parseAllowedMask in socketTransport.c, prefixLen of mask is compared with
>> a maxValue (32 for IPv4, 128 otherwise). This fails if it is larger than
>> 32, because getaddrinfo seems to detect IPv4 family, if IPv6 address has set
>> only some of the last 32 Bits. So we take the wrong maxValue.
>
> Joachim Kern has updated the pull request incrementally with one additional
> commit since the last revision:
>
> cosmetic changes
src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c line 420:
> 418: struct in_addr addr;
> 419: struct in6_addr addr6;
> 420: if (inet_pton (AF_INET6, buffer, &addr6) == 1) {
space is not needed before brace
Suggestion:
if (inet_pton(AF_INET6, buffer, &addr6) == 1) {
src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c line 422:
> 420: if (inet_pton (AF_INET6, buffer, &addr6) == 1) {
> 421: *isIPv4 = 0;
> 422: } else if (inet_pton (AF_INET, buffer, &addr) == 1) {
Space before brace
Suggestion:
} else if (inet_pton(AF_INET, buffer, &addr) == 1) {
src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c line 425:
> 423: // IPv4 address - convert to mapped IPv6
> 424: struct sockaddr sa;
> 425: memcpy(&(((struct sockaddr_in*)&sa)->sin_addr), &addr, 4);
Suggestion:
memcpy(&(((struct sockaddr_in*)&sa)->sin_addr), &addr, sizeof(addr));
src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c line 426:
> 424: struct sockaddr sa;
> 425: memcpy(&(((struct sockaddr_in*)&sa)->sin_addr), &addr, 4);
> 426: convertIPv4ToIPv6(&sa, &addr6);
Comment for convertIPv4ToIPv6 says: "Input is sockaddr just because all clients
have it."
Now it's not true.
I suggest to update convertIPv4ToIPv6 function and make 1st argument `const
struct in_addr` (need to update other call of the function from isPeerAllowed())
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17374#discussion_r1449312487
PR Review Comment: https://git.openjdk.org/jdk/pull/17374#discussion_r1449312811
PR Review Comment: https://git.openjdk.org/jdk/pull/17374#discussion_r1449314051
PR Review Comment: https://git.openjdk.org/jdk/pull/17374#discussion_r1449329711