iliaa Sat Dec 30 20:21:39 2006 UTC
Modified files: (Branch: PHP_4_4)
/php-src/ext/shmop shmop.c
Log:
MFH: Added missing resource type checks
http://cvs.php.net/viewvc.cgi/php-src/ext/shmop/shmop.c?r1=1.23.8.3.2.1&r2=1.23.8.3.2.2&diff_format=u
Index: php-src/ext/shmop/shmop.c
diff -u php-src/ext/shmop/shmop.c:1.23.8.3.2.1
php-src/ext/shmop/shmop.c:1.23.8.3.2.2
--- php-src/ext/shmop/shmop.c:1.23.8.3.2.1 Sun Jan 1 13:46:56 2006
+++ php-src/ext/shmop/shmop.c Sat Dec 30 20:21:39 2006
@@ -16,7 +16,7 @@
| Ilia Alshanetsky <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: shmop.c,v 1.23.8.3.2.1 2006/01/01 13:46:56 sniper Exp $ */
+/* $Id: shmop.c,v 1.23.8.3.2.2 2006/12/30 20:21:39 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -78,6 +78,16 @@
ZEND_GET_MODULE(shmop)
#endif
+#define PHP_SHMOP_GET_RES \
+ shmop = zend_list_find(shmid, &type); \
+ if (!shmop) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid); \
+ RETURN_FALSE; \
+ } else if (type != shm_type) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a shmop
resource"); \
+ RETURN_FALSE; \
+ } \
+
/* {{{ rsclean
*/
static void rsclean(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -210,13 +220,8 @@
WRONG_PARAM_COUNT;
}
- shmop = zend_list_find(shmid, &type);
+ PHP_SHMOP_GET_RES
- if (!shmop) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid);
- RETURN_FALSE;
- }
-
if (start < 0 || start > shmop->size) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "start is out of
range");
RETURN_FALSE;
@@ -255,12 +260,7 @@
WRONG_PARAM_COUNT;
}
- shmop = zend_list_find(shmid, &type);
-
- if (!shmop) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid);
- RETURN_FALSE;
- }
+ PHP_SHMOP_GET_RES
zend_list_delete(shmid);
}
@@ -278,12 +278,7 @@
WRONG_PARAM_COUNT;
}
- shmop = zend_list_find(shmid, &type);
-
- if (!shmop) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid);
- RETURN_FALSE;
- }
+ PHP_SHMOP_GET_RES
RETURN_LONG(shmop->size);
}
@@ -304,12 +299,7 @@
WRONG_PARAM_COUNT;
}
- shmop = zend_list_find(shmid, &type);
-
- if (!shmop) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid);
- RETURN_FALSE;
- }
+ PHP_SHMOP_GET_RES
if ((shmop->shmatflg & SHM_RDONLY) == SHM_RDONLY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "trying to write to
a read only segment");
@@ -340,12 +330,7 @@
WRONG_PARAM_COUNT;
}
- shmop = zend_list_find(shmid, &type);
-
- if (!shmop) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "no shared memory
segment with an id of [%lu]", shmid);
- RETURN_FALSE;
- }
+ PHP_SHMOP_GET_RES
if (shmctl(shmop->shmid, IPC_RMID, NULL)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "can't mark segment
for deletion (are you the owner?)");
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php