]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* java/net/natPlainDatagramSocketImpl.cc (receive):
authorjsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jun 2002 16:25:00 +0000 (16:25 +0000)
committerjsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jun 2002 16:25:00 +0000 (16:25 +0000)
Check bounds of argument to FD_SET.
(setOption): Throw exception if socket is closed.

* java/net/natPlainSocketImpl.cc (accept, read):
Check bounds of argument to FD_SET.
(setOption): Throw exception if socket is closed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54750 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/net/natPlainDatagramSocketImpl.cc
libjava/java/net/natPlainSocketImpl.cc

index d189b02af9aa75150f1c88da8c803b9eb285c757..9de49b06fc79bb3b4534b7580436de7de271e8d7 100644 (file)
@@ -1,3 +1,13 @@
+2002-06-18  Jeff Sturm  <jsturm@one-point.com>
+
+       * java/net/natPlainDatagramSocketImpl.cc (receive):
+       Check bounds of argument to FD_SET.
+       (setOption): Throw exception if socket is closed.
+
+       * java/net/natPlainSocketImpl.cc (accept, read):
+       Check bounds of argument to FD_SET.
+       (setOption): Throw exception if socket is closed.
+
 2002-06-18  Tom Tromey  <tromey@redhat.com>
 
        * gcj/javaprims.h: Updated class declaration list.
index 3c318d7667cda40bee712c4618751b307df10dcd..4db99121dd7e5f132a6592460be348fddb92d2e5 100644 (file)
@@ -361,7 +361,7 @@ java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
 // FIXME: implement timeout support for Win32
 #ifndef WIN32
   // Do timeouts via select since SO_RCVTIMEO is not always available.
-  if (timeout > 0)
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
     {
       fd_set rset;
       struct timeval tv;
@@ -501,6 +501,9 @@ java::net::PlainDatagramSocketImpl::setOption (jint optID,
   int val;
   socklen_t val_len = sizeof (val);
 
+  if (fnum < 0)
+    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
   if (_Jv_IsInstanceOf (value, &BooleanClass))
     {
       java::lang::Boolean *boolobj = 
index e16c372d989f9135adec604ead8b78f81d35eadf..4a75e980073e3468363b10fc3b1ca16d3befd260 100644 (file)
@@ -369,7 +369,7 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
 // FIXME: implement timeout support for Win32
 #ifndef WIN32
   // Do timeouts via select since SO_RCVTIMEO is not always available.
-  if (timeout > 0)
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
     {
       fd_set rset;
       struct timeval tv;
@@ -516,7 +516,7 @@ java::net::PlainSocketImpl::read(void)
 // FIXME: implement timeout support for Win32
 #ifndef WIN32
   // Do timeouts via select.
-  if (timeout > 0)
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
   {
     // Create the file descriptor set.
     fd_set read_fds;
@@ -575,7 +575,7 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
 // FIXME: implement timeout support for Win32
 #ifndef WIN32
   // Do timeouts via select.
-  if (timeout > 0)
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
   {
     // Create the file descriptor set.
     fd_set read_fds;
@@ -662,6 +662,7 @@ java::net::PlainSocketImpl::available(void)
 
 #if defined(HAVE_SELECT)
   if (! num_set)
+  if (! num_set && fnum >= 0 && fnum < FD_SETSIZE)
     {
       fd_set rd;
       FD_ZERO (&rd);
@@ -689,6 +690,9 @@ java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value)
   int val;
   socklen_t val_len = sizeof (val);
 
+  if (fnum < 0)
+    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
   if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
     {
       java::lang::Boolean *boolobj =