RFR: 8275319 java.net.NetworkInterface throws java.lang.Error instead of SocketException [v3]

Alan Bateman alanb at openjdk.java.net
Tue Oct 19 10:29:52 UTC 2021


On Tue, 19 Oct 2021 07:53:47 GMT, Daniel Jeliński <duke at openjdk.java.net> wrote:

>> src/java.base/windows/native/libnet/NetworkInterface_winXP.c line 123:
>> 
>>> 121:                 // not an error
>>> 122:                 *adapters = NULL;
>>> 123:                 return ERROR_SUCCESS;
>> 
>> Mapping ERROR_NO_DATA to ERROR_SUCCESS is probably correct here. Could this explain bug reports that seem to be from configurations with no IP addresses plumbed?
>
> I suppose it could. But in order to get ERROR_NO_DATA here one would need to disable loopback interface. I couldn't find how to do that.

There has been one or two reports from configurations that appear to have no interface or no IP addresses. I don't think we've been able to create those configurations to duplicate. In any case, treat NO_DATA as SUCCESS seems correct here.

>> src/java.base/windows/native/libnet/NetworkInterface_winXP.c line 232:
>> 
>>> 230: int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
>>> 231: {
>>> 232:     int ret, flags;
>> 
>> This looks right but I can't relate this to your comment about the crash.
>
> let me try to explain this clang-style:
> - `tableP` contains [random garbage](https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L233)
> - [lookupIPAddrTable](https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L266) returns error, does not touch `tableP`
> - `ret` is unsigned, so [this is never true](https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L267)
> - uninitialized `tableP` is passed to [enumAddresses_win_ipaddrtable](https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface_winXP.c#L272)
> - `enumAddresses_win_ipaddrtable` [dereferences](https://github.com/openjdk/jdk/blob/a6c89e231872e7fab236ed87b5ccf44a189d6786/src/java.base/windows/native/libnet/NetworkInterface.c#L440) `tableP` and crashes

Thanks for this, I hadn't spotted the broken code that tests if loopupIPAddrTable  fails.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5956


More information about the net-dev mailing list