com php-src: revamped ext/shmop: ext/shmop/php_shmop.h ex t/shmop/shmop.c

From: Date: Thu, 09 Jan 2014 08:51:21 +0000
Subject: com php-src: revamped ext/shmop: ext/shmop/php_shmop.h ex t/shmop/shmop.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75557@lists.php.net to get a copy of this message
Commit: 6951bea25ecf73fa7d3ec272f6fa552f464e4cbe Author: Anatol Belski <ab@php.net> Thu, 9 Jan 2014 09:51:21 +0100 Parents: 9dd5099566bcbfc84e00ba22f9ca40929c626160 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6951bea25ecf73fa7d3ec272f6fa552f464e4cbe Log: revamped ext/shmop Changed paths: M ext/shmop/php_shmop.h M ext/shmop/shmop.c Diff: diff --git a/ext/shmop/php_shmop.h b/ext/shmop/php_shmop.h index 2779fe1..e0e0448 100644 --- a/ext/shmop/php_shmop.h +++ b/ext/shmop/php_shmop.h @@ -45,7 +45,7 @@ struct php_shmop int shmflg; int shmatflg; char *addr; - int size; + php_int_t size; }; typedef struct { diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c index e0aa122..72d59bc 100644 --- a/ext/shmop/shmop.c +++ b/ext/shmop/shmop.c @@ -159,7 +159,7 @@ PHP_FUNCTION(shmop_open) php_int_t key, mode, size; struct php_shmop *shmop; struct shmid_ds shm; - int rsid; + php_int_t rsid; char *flags; php_size_t flags_len; @@ -172,6 +172,11 @@ PHP_FUNCTION(shmop_open) RETURN_FALSE; } + if (key > INT_MAX || key < INT_MIN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The system's id must be between %d and %d", INT_MIN, INT_MAX); + goto err; + } + shmop = emalloc(sizeof(struct php_shmop)); memset(shmop, 0, sizeof(struct php_shmop)); @@ -202,9 +207,14 @@ PHP_FUNCTION(shmop_open) goto err; } - if (shmop->shmflg & IPC_CREAT && shmop->size < 1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Shared memory segment size must be greater than zero"); - goto err; + if (shmop->shmflg & IPC_CREAT) { + if (shmop->size < 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Shared memory segment size must be greater than zero"); + goto err; + } else if (shmop->size > INT_MAX) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Shared memory segment size must be less than or equal to %d", INT_MAX); + goto err; + } } shmop->shmid = shmget(shmop->key, shmop->size, shmop->shmflg); @@ -242,7 +252,7 @@ PHP_FUNCTION(shmop_read) struct php_shmop *shmop; int type; char *startaddr; - int bytes; + php_int_t bytes; char *return_string; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iii", &shmid, &start, &count) == FAILURE) { @@ -314,7 +324,7 @@ PHP_FUNCTION(shmop_write) { struct php_shmop *shmop; int type; - int writesize; + php_int_t writesize; php_int_t shmid, offset; char *data; php_size_t data_len;

« previous php.cvs (#75557) next »