PATCH: natPlainDatagramSocketImplXXXX.cc offset bug.

Michael Koch konqueror@gmx.de
Thu Mar 25 19:22:00 GMT 2004


On Sun, Mar 21, 2004 at 07:18:43PM +0100, Norbert Frese wrote:
> 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.

Can't we ditch maxlen completely then and use p->maxlen directly where
needed ? I see no performance loss with CNI here.

>    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)

Norbert: Can you please right a GNU conform changelog entry for this ? I
can the commit this easily.


Michael



More information about the Java mailing list