summaryrefslogtreecommitdiff
path: root/ext/sysvshm
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-02-24 15:44:43 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-02-24 15:44:43 +0000
commite4ff13e43e13e1bc0c9a3a7500668b6986f9b0e8 (patch)
treec4dcc64ec89e504bafce93d86858f73781207b46 /ext/sysvshm
parent44aefd1ea07eae2d1bb9893925dd4e4cc2665614 (diff)
downloadphp-git-e4ff13e43e13e1bc0c9a3a7500668b6986f9b0e8.tar.gz
Unify validation of shm segment size inside shm_attach()
Diffstat (limited to 'ext/sysvshm')
-rw-r--r--ext/sysvshm/sysvshm.c5
-rw-r--r--ext/sysvshm/tests/002.phpt22
2 files changed, 16 insertions, 11 deletions
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index c2dfbab5bd..c8092ef2cc 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -134,6 +134,11 @@ PHP_FUNCTION(shm_attach)
shm_key = Z_LVAL_PP(arg_key);
}
+ if (shm_size < 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Segment size must be greater then zero.");
+ RETURN_FALSE;
+ }
+
shm_list_ptr = (sysvshm_shm *) emalloc(sizeof(sysvshm_shm));
/* get the id from a specified key or create new shared memory */
diff --git a/ext/sysvshm/tests/002.phpt b/ext/sysvshm/tests/002.phpt
index 81bb0cd495..21651dee58 100644
--- a/ext/sysvshm/tests/002.phpt
+++ b/ext/sysvshm/tests/002.phpt
@@ -33,35 +33,35 @@ shm_remove($s);
echo "Done\n";
?>
--EXPECTF--
-Warning: Wrong parameter count for shm_attach() in %s on line %d
+Warning: Wrong parameter count for shm_attach() in %s/sysvshm/tests/002.php on line %d
NULL
-Warning: Wrong parameter count for shm_attach() in %s on line %d
+Warning: Wrong parameter count for shm_attach() in %s/sysvshm/tests/002.php on line %d
NULL
-Warning: shm_attach(): failed for key 0xffffffff: memorysize too small in %s on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s/sysvshm/tests/002.php on line %d
bool(false)
-Warning: shm_attach(): failed for key 0x0: Invalid argument in %s on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s/sysvshm/tests/002.php on line %d
bool(false)
-Warning: shm_attach(): failed for key 0x7b: Invalid argument in %s on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s/sysvshm/tests/002.php on line %d
bool(false)
-Warning: shm_attach(): failed for key %s: Invalid argument in %s on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s/sysvshm/tests/002.php on line %d
bool(false)
-Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on line %d
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s/sysvshm/tests/002.php on line %d
-Warning: shm_attach(): failed for key %s: memorysize too small in %s on line %d
+Warning: shm_attach(): Segment size must be greater then zero. in %s/sysvshm/tests/002.php on line %d
bool(false)
-Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on line %d
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s/sysvshm/tests/002.php on line %d
int(%d)
-Warning: shm_remove(): The parameter is not a valid shm_identifier in %s on line %d
+Warning: shm_remove(): The parameter is not a valid shm_identifier in %s/sysvshm/tests/002.php on line %d
int(%d)
int(%d)
int(%d)
int(%d)
-Done
+Done \ No newline at end of file