2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-13 14:11:18 +08:00

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
This commit is contained in:
Jeff Sturm 2002-06-18 16:25:00 +00:00 committed by Jeff Sturm
parent 18ba380b3a
commit 347258aef0
3 changed files with 21 additions and 4 deletions

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

@ -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 =

@ -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 =