diff options
author | Chris Vandomelen <chrisv@php.net> | 2000-08-20 19:48:42 +0000 |
---|---|---|
committer | Chris Vandomelen <chrisv@php.net> | 2000-08-20 19:48:42 +0000 |
commit | 8ef1279f2b47149e4d6bbb162b960eea6c5639ca (patch) | |
tree | c6a1ca1cb23dbe2f3a63fba07f3d28b1caab320b | |
parent | 4d6f3b40a7844ae818fa966a2c1c05466a1d8976 (diff) | |
download | php-git-8ef1279f2b47149e4d6bbb162b960eea6c5639ca.tar.gz |
Added another bug fix to detect for negative values being passed into the
fd_*() functions, as passing negative values would cause PHP to segfault.
-rw-r--r-- | ext/sockets/sockets.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 759f2c7b0e..eb48e91f6e 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -271,6 +271,11 @@ PHP_FUNCTION(fd_set) ZEND_FETCH_RESOURCE(the_set, fd_set *, set, -1, "File descriptor set", SOCKETSG(le_destroy)); + if (Z_LVAL_PP(fd) < 0) { + php_error(E_WARNING, "Can't set negative fd falues in a set"); + RETURN_FALSE; + } + FD_SET(Z_LVAL_PP(fd), the_set); RETURN_TRUE; @@ -293,6 +298,11 @@ PHP_FUNCTION(fd_clear) ZEND_FETCH_RESOURCE(the_set, fd_set *, set, -1, "File descriptor set", SOCKETSG(le_destroy)); + if (Z_LVAL_PP(fd) < 0) { + php_error(E_WARNING, "Can't clear negative fd values in a set"); + RETURN_FALSE; + } + FD_CLR(Z_LVAL_PP(fd), the_set); RETURN_TRUE; @@ -315,6 +325,11 @@ PHP_FUNCTION(fd_isset) ZEND_FETCH_RESOURCE(the_set, fd_set *, set, -1, "File descriptor set", SOCKETSG(le_destroy)); + if (Z_LVAL_PP(fd) < 0) { + php_error(E_WARNING, "Can't check for negative fd values in a set"); + RETURN_FALSE; + } + if (FD_ISSET(Z_LVAL_PP(fd), the_set)) { RETURN_TRUE; } |