PATCH: natPlainDatagramSocketImplXXXX.cc offset bug.

Norbert Frese postfach@nfrese.net
Thu Mar 25 06:00:00 GMT 2004


This patches fixes a buffer-offset related bug in
natPlainDatagramSocketImplPosix.cc and
natPlainDatagramSocketImplWin32.cc.

(gnu::java::net::PlainDatagramSocketImpl::peekData): Do not subtract
buffer offset from maxlen. 
(gnu::java::net::PlainDatagramSocketImpl::receive): The same.

With this patch the mauve
gnu.testlet.java.net.DatagramPacket.DatagramPacketOffset test 
passes.

Norbert

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


Index: gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
===================================================================
RCS file:
/cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc,vretrieving revision 1.7
diff -u -r1.7 natPlainDatagramSocketImplPosix.cc
--- gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc 17 Mar
2004 08:10:28 -0000      1.7
+++ gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc 21 Mar
2004 18:10:09 -0000
@@ -210,7 +210,7 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
   jbyte *dbytes = elements (p->getData()) + p->getOffset();
-  jint maxlen = p->maxlen - p->getOffset();
+  jint maxlen = p->maxlen; // Max bytes starting from offset.
   ssize_t retlen = 0;
  
   // Do timeouts via select since SO_RCVTIMEO is not always available.
@@ -335,7 +335,7 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
   jbyte *dbytes = elements (p->getData()) + p->getOffset();
-  jint maxlen = p->maxlen - p->getOffset();
+  jint maxlen = p->maxlen;  // Max bytes starting from offset.
   ssize_t retlen = 0;
  
   // Do timeouts via select since SO_RCVTIMEO is not always available.
Index: gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc
===================================================================
RCS file:
/cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc,vretrieving revision 1.8
diff -u -r1.8 natPlainDatagramSocketImplWin32.cc
--- gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc 17 Mar
2004 08:10:28 -0000      1.8
+++ gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc 21 Mar
2004 18:10:10 -0000
@@ -202,7 +202,7 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
   jbyte *dbytes = elements (p->getData()) + p->getOffset();
-  jint maxlen = p->maxlen - p->getOffset();
+  jint maxlen = p->maxlen; // Max bytes starting from offset.
   ssize_t retlen = 0;
  
   if (timeout > 0)
@@ -321,7 +321,7 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
   jbyte *dbytes = elements (p->getData()) + p->getOffset();
-  jint maxlen = p->maxlen - p->getOffset();
+  jint maxlen = p->maxlen; // Max bytes starting from offset.
   ssize_t retlen = 0;
  
   if (timeout > 0)




More information about the Java mailing list