RFR: 8170544: Fix code scan findings in libnet

Langer, Christoph christoph.langer at sap.com
Thu Dec 29 13:20:44 UTC 2016


Hi Goetz,

thanks for reviewing this.

I have addressed your comments in a new webrev: http://cr.openjdk.java.net/~clanger/webrevs/8170544.1/

Here's the details:

> http://cr.openjdk.java.net/~clanger/webrevs/8170544.0/src/java.base/share/na
> tive/libnet/net_util.c.udiff.html
> +     * check now to whether we have IPv6 on this platform and if the
> superfluous 'to'

Removed.

> http://cr.openjdk.java.net/~clanger/webrevs/8170544.0/src/java.base/unix/nati
> ve/libnet/NetworkInterface.c.udiff.html
> For the records: you add closing the connection in an error case.

Yes.

> http://cr.openjdk.java.net/~clanger/webrevs/8170544.0/src/java.base/unix/nati
> ve/libnet/net_util_md.c.udiff.html
> Is it safe to do memset here?  I think memset in the ipv4/v6 cases with the
> corresponding sizes is safer.
> Len is not passed in all the times. Else you could memset with len.
> (You change len to '0' in
> http://cr.openjdk.java.net/~clanger/webrevs/8170544.0/src/java.base/unix/nati
> ve/libnio/ch/DatagramChannelImpl.c.udiff.html )
> If you are sure you always pass a full SOCKETADDRESS this is fine, though.
> Same holds for the windows size.
> Overall, the len field is quite superfluous now, isn't it?  But this should not be
> changed in this change I think.

I think this is okay as is. NET_InetAddressToSockaddr takes a pointer to SOCKETADDRESS and then works on the pointed to memory (sizeof SOCKETADDRESS). Parameter len is only used as output, not as input that specifies the length of the incoming buffer. I have updated the documentation in http://cr.openjdk.java.net/~clanger/webrevs/8170544.1/src/java.base/share/native/libnet/net_util.h.cdiff.html

> http://cr.openjdk.java.net/~clanger/webrevs/8170544.0/src/java.base/windows
> /native/libnet/TwoStacksPlainDatagramSocketImpl.c.udiff.html
> Please add spaces around '=': fd=-1

Done in all places.

Best regards
Christoph



More information about the net-dev mailing list