classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: avoid buffer overflow in socket read


From: Anthony Green
Subject: [cp-patches] Patch: avoid buffer overflow in socket read
Date: Mon, 26 Dec 2005 17:52:09 -0800

This next patch computes right amount of data to read from a socket to
stuff in a Buffer.  When dst.limit < dst.capacity, we're trying to put
too much data into the buffer and we get a buffer overflow exception.

Ok to apply?

Thanks,

AG



2005-12-26  Anthony Green  <address@hidden>

        * gnu/java/nio/SocketChannelImpl.java (read): Compute the right amount
        of data to read (dst.remaining()).


--- gnu/java/nio/SocketChannelImpl.java.~1.28.~ 2005-11-11 04:04:03.000000000 
-0800
+++ gnu/java/nio/SocketChannelImpl.java 2005-12-26 17:34:14.000000000 -0800
@@ -220,7 +220,7 @@
     int offset = 0;
     InputStream input = socket.getInputStream();
     int available = input.available();
-    int len = dst.capacity() - dst.position();
+    int len = dst.remaining();
        
     if ((! isBlocking()) && available == 0)
       return 0;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]