Commit 347258ae by Jeff Sturm Committed by Jeff Sturm

natPlainDatagramSocketImpl.cc (receive): Check bounds of argument to FD_SET.

	* 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.

From-SVN: r54750
parent 18ba380b
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> 2002-06-18 Tom Tromey <tromey@redhat.com>
* gcj/javaprims.h: Updated class declaration list. * gcj/javaprims.h: Updated class declaration list.
......
...@@ -361,7 +361,7 @@ java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p) ...@@ -361,7 +361,7 @@ java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
// FIXME: implement timeout support for Win32 // FIXME: implement timeout support for Win32
#ifndef WIN32 #ifndef WIN32
// Do timeouts via select since SO_RCVTIMEO is not always available. // 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; fd_set rset;
struct timeval tv; struct timeval tv;
...@@ -501,6 +501,9 @@ java::net::PlainDatagramSocketImpl::setOption (jint optID, ...@@ -501,6 +501,9 @@ java::net::PlainDatagramSocketImpl::setOption (jint optID,
int val; int val;
socklen_t val_len = sizeof (val); socklen_t val_len = sizeof (val);
if (fnum < 0)
throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
if (_Jv_IsInstanceOf (value, &BooleanClass)) if (_Jv_IsInstanceOf (value, &BooleanClass))
{ {
java::lang::Boolean *boolobj = java::lang::Boolean *boolobj =
......
...@@ -369,7 +369,7 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s) ...@@ -369,7 +369,7 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
// FIXME: implement timeout support for Win32 // FIXME: implement timeout support for Win32
#ifndef WIN32 #ifndef WIN32
// Do timeouts via select since SO_RCVTIMEO is not always available. // 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; fd_set rset;
struct timeval tv; struct timeval tv;
...@@ -516,7 +516,7 @@ java::net::PlainSocketImpl::read(void) ...@@ -516,7 +516,7 @@ java::net::PlainSocketImpl::read(void)
// FIXME: implement timeout support for Win32 // FIXME: implement timeout support for Win32
#ifndef WIN32 #ifndef WIN32
// Do timeouts via select. // Do timeouts via select.
if (timeout > 0) if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
{ {
// Create the file descriptor set. // Create the file descriptor set.
fd_set read_fds; fd_set read_fds;
...@@ -575,7 +575,7 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count) ...@@ -575,7 +575,7 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
// FIXME: implement timeout support for Win32 // FIXME: implement timeout support for Win32
#ifndef WIN32 #ifndef WIN32
// Do timeouts via select. // Do timeouts via select.
if (timeout > 0) if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
{ {
// Create the file descriptor set. // Create the file descriptor set.
fd_set read_fds; fd_set read_fds;
...@@ -662,6 +662,7 @@ java::net::PlainSocketImpl::available(void) ...@@ -662,6 +662,7 @@ java::net::PlainSocketImpl::available(void)
#if defined(HAVE_SELECT) #if defined(HAVE_SELECT)
if (! num_set) if (! num_set)
if (! num_set && fnum >= 0 && fnum < FD_SETSIZE)
{ {
fd_set rd; fd_set rd;
FD_ZERO (&rd); FD_ZERO (&rd);
...@@ -689,6 +690,9 @@ java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value) ...@@ -689,6 +690,9 @@ java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value)
int val; int val;
socklen_t val_len = sizeof (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$)) if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
{ {
java::lang::Boolean *boolobj = java::lang::Boolean *boolobj =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment