Patch: receiveing UDP packets

Tom Tromey tromey@redhat.com
Mon May 10 17:40:00 GMT 2004


>>>>> "Michael" == Michael Koch <konqueror@gmx.de> writes:

Michael> Ok to commit to trunk ? This should probably go into 3.4 too ?

Does this fix a regression?  I thought 3.4 was in regressions-only
mode.

Michael>    jbyte *dbytes = elements (p->getData()) + p->getOffset();
Michael> -  jint maxlen = p->maxlen - p->getOffset();

Does it make sense to remove the offset from `maxlen' but keep it for
`dbytes'?  I don't get that.  Plus, don't we want to keep `offset' in
the computation anyway?

Also, it seems to me that we're missing some checking in
DatagramPacket.  At least, the class javadoc claims:

 * Note that for all method below where the buffer length passed by the
 * caller cannot exceed the actually length of the byte array passed as
 * the buffer, if this condition is not true, then the method silently
 * reduces the length value to maximum allowable value.

... but I don't see code to actually implement this.  setLength tries
to throw an exception in this situation (though it may be vulnerable
to wrapping).  So there's at least a little inconsistency.

Tom



More information about the Java-patches mailing list