[sctp-dev] Address to zero length buffer

Timo Völker timo.voelker at fh-muenster.de
Thu Mar 22 07:37:52 UTC 2018


Hi,

I created a small example which uses SCTP based on the one I found on http://www.oracle.com/technetwork/articles/javase/index-139946.html. Here is my code.

https://github.com/msvoelker/java-sctp/

As I wrote in the README.md, it works on Linux, but does not on FreeBSD. Since you do not support FreeBSD thats understandable. However, I think I found something that still should be fixed.

On FreeBSD I used truss to analyse the system calls. I saw the following call.

sendmsg(7,{0x7fffdfffd5d0,0,[{"4:48:53 PM Fri 16 Mar 18, Centra"...,47}],1,{{level=IPPROTO_SCTP,type=SCTP_SNDRCV,data={sid=0,flgs=0,ppid=0,ctx=0,ttl=0,id=0}}},144,0},0) ERR#22 'Invalid argument'

Here, 0x7fffdfffd5d0 seems to be an address to a buffer, where sendmsg expects a peer socket address. The following 0 says that this buffer has a length of 0 bytes. This seems to be OK for Linux, but for FreeBSD (and probably macOS as well) its an invalid argument. For FreeBSD, If length is 0, the address must be NULL.

I think I found the corresponding lines in the following file.

http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c

The path contains the name solaris, but I guessed you use the same file for other Unix OS. Right?

In the method

Java_sun_nio_ch_sctp_SctpChannelImpl_send0

if targetAddress == NULL then

msg->msg_name = &sa;
msg->msg_namelen = sa_len; // == 0

As I wrote, msg->msg_name needs to be NULL, if msg->msg_namelen is 0.

I could not find a way to help here other than writing this e-mail. If there is something else I can do, let me know.

Thanks!

Timo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5243 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/sctp-dev/attachments/20180322/82332b4b/smime.p7s>


More information about the sctp-dev mailing list