Bug in libgcj UDP network classes

Norbert Frese postfach@nfrese.net
Thu Nov 20 20:28:00 GMT 2003


Hi list!

I have found a bug in the libgcj network-classes:

It seems that the length of data of an incoming UDP packet gets
overwritten by other UDP packets queueing up on the same socket. 
-> When you call DatagramSocket.receive() the wrong number of bytes is 
copied to the byte[] buffer.

I have written a little test-program 'UDPTest', which sends two packets
in an endless loop to itself:

packet1 contains the String: "Hello World 1234567890 ++++++++++++++"
packet2 contains the String: "World Hello 0987654321"

UDPTest output gcj (3.4 from CVS, checked out today):

$ ./udptest_gcj
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 length=22
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 length=22
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 length=22
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 length=22
got packet:World Hello 0987654321 length=22

UDPTest output sun jre:
 
$ java UDPTest
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22
got packet:Hello World 1234567890 ++++++++++++++ length=37
got packet:World Hello 0987654321 length=22

Attached is the source of UDPTest.

regards 
norbert




-------------- next part --------------
A non-text attachment was scrubbed...
Name: udp_testsuite.tar.gz
Type: application/x-compressed-tar
Size: 1293 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20031120/b3d8805b/attachment.bin>


More information about the Java mailing list