jason           Tue Sep 10 00:12:56 2002 EDT

  Modified files:              
    /php4/ext/sockets   sockets.c 
  Log:
  Fix crash bug and memory leak in vectors
  #still need to revisit how these are done, i.e. they are not binary safe
  
  
Index: php4/ext/sockets/sockets.c
diff -u php4/ext/sockets/sockets.c:1.120 php4/ext/sockets/sockets.c:1.121
--- php4/ext/sockets/sockets.c:1.120    Wed Aug 28 02:15:13 2002
+++ php4/ext/sockets/sockets.c  Tue Sep 10 00:12:55 2002
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c,v 1.120 2002/08/28 06:15:13 jason Exp $ */
+/* $Id: sockets.c,v 1.121 2002/09/10 04:12:55 jason Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1100,6 +1100,8 @@
                vector_array[i].iov_base        = (char*)emalloc(Z_LVAL_PP(args[j]));
                vector_array[i].iov_len         = Z_LVAL_PP(args[j]);
        }
+       
+       efree(args);
 
        vector = emalloc(sizeof(php_iovec_t));
        vector->iov_array = vector_array;
@@ -1122,7 +1124,7 @@
 
        ZEND_FETCH_RESOURCE(vector, php_iovec_t *, &iovec_id, -1, le_iov_name, le_iov);
 
-       if (iovec_position > vector->count) {
+       if (iovec_position >= vector->count) {
                php_error(E_WARNING, "%s() can't access a vector position past the 
amount of vectors set in the array", get_active_function_name(TSRMLS_C));
                RETURN_EMPTY_STRING();
        }
@@ -1146,7 +1148,7 @@
 
        ZEND_FETCH_RESOURCE(vector, php_iovec_t *, &iovec_id, -1, le_iov_name, le_iov);
 
-       if (iovec_position > vector->count) {
+       if (iovec_position >= vector->count) {
                php_error(E_WARNING, "%s() can't access a vector position outside of 
the vector array bounds", get_active_function_name(TSRMLS_C));
                RETURN_FALSE;
        }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to