]> granicus.if.org Git - php/commitdiff
MFH: Added missing resource validation checks
authorIlia Alshanetsky <iliaa@php.net>
Sat, 30 Dec 2006 20:50:50 +0000 (20:50 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sat, 30 Dec 2006 20:50:50 +0000 (20:50 +0000)
ext/sysvshm/sysvshm.c

index 9aca048364bc14b4128cd1e34fbf92575bfee8cf..54cf8c235900467f6a6bccb4268a8ba194ff3424 100644 (file)
@@ -213,7 +213,7 @@ PHP_FUNCTION(shm_remove)
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
 
-       if (!shm_list_ptr) {
+       if (!shm_list_ptr || type != php_sysvshm.le_shm) {
                php_error(E_WARNING, "The parameter is not a valid shm_identifier");
                RETURN_FALSE;
        }
@@ -224,7 +224,7 @@ PHP_FUNCTION(shm_remove)
        } 
 
        RETURN_TRUE;
-}
+} 
 /* }}} */
 
 /* {{{ proto int shm_put_var(int shm_identifier, int variable_key, mixed variable)
@@ -249,7 +249,7 @@ PHP_FUNCTION(shm_put_var)
        key = Z_LVAL_PP(arg_key);
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
-       if (type!=php_sysvshm.le_shm) {
+       if (!shm_list_ptr || type != php_sysvshm.le_shm) {
                php_error(E_WARNING, "%ld is not a SysV shared memory index", id);
                RETURN_FALSE;
        }
@@ -296,7 +296,7 @@ PHP_FUNCTION(shm_get_var)
        key = Z_LVAL_PP(arg_key);
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
-       if (type!=php_sysvshm.le_shm) {
+       if (!shm_list_ptr || type != php_sysvshm.le_shm) {
                php_error(E_WARNING, "%ld is not a SysV shared memory index", id);
                RETURN_FALSE;
        }
@@ -342,7 +342,7 @@ PHP_FUNCTION(shm_remove_var)
        key = Z_LVAL_PP(arg_key);
 
        shm_list_ptr = (sysvshm_shm *) zend_list_find(id, &type);
-       if (type!=php_sysvshm.le_shm) {
+       if (!shm_list_ptr || type != php_sysvshm.le_shm) {
                php_error(E_WARNING, "%ld is not a SysV shared memory index", id);
                RETURN_FALSE;
        }