summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-12-25 22:36:57 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-12-25 22:36:57 +0000
commit52d53543ac748489d108dc6988d02f51fd69b8d6 (patch)
tree224f13b4b4c89b139ed1bb7f9c3236c730f23d94
parent9c2b6efb77637ec5cc35e6872d4ce4296021a2ea (diff)
downloadphp-git-52d53543ac748489d108dc6988d02f51fd69b8d6.tar.gz
Allocation safety checks
-rw-r--r--ext/pgsql/pgsql.c2
-rw-r--r--ext/soap/php_encoding.c2
-rwxr-xr-xext/spl/spl_directory.c2
-rw-r--r--ext/standard/math.c2
-rw-r--r--main/main.c9
5 files changed, 11 insertions, 6 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 2f3f3219a7..08a9948562 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -2102,7 +2102,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
Bucket *p;
fci.param_count = 0;
- fci.params = emalloc(sizeof(zval*) * ht->nNumOfElements);
+ fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
p = ht->pListHead;
while (p != NULL) {
fci.params[fci.param_count++] = (zval**)p->pData;
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 0f0b281c25..5b6acdcae3 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -974,7 +974,7 @@ static xmlNodePtr to_xml_double(encodeTypePtr type, zval *data, int style, xmlNo
convert_to_double(&tmp);
}
- str = (char *) emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
+ str = (char *) safe_emalloc(EG(precision), 1, MAX_LENGTH_OF_DOUBLE + 1);
php_gcvt(Z_DVAL(tmp), EG(precision), '.', 'E', str);
xmlNodeSetContentLen(ret, BAD_CAST(str), strlen(str));
efree(str);
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index ff8548a821..e07360a498 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1367,7 +1367,7 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS
}
if (intern->u.file.max_line_len > 0) {
- buf = emalloc((intern->u.file.max_line_len + 1) * sizeof(char));
+ buf = safe_emalloc((intern->u.file.max_line_len + 1), sizeof(char), 0);
if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len, &line_len) == NULL) {
efree(buf);
buf = NULL;
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 79a1693868..0ee6f4ff99 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -976,7 +976,7 @@ PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char tho
dec = MAX(0, dec);
PHP_ROUND_WITH_FUZZ(d, dec);
- tmplen = spprintf(&tmpbuf, 0, "%.*f", dec, d);
+ tmplen = spprintf(&tmpbuf, 0, "%.*F", dec, d);
if (tmpbuf == NULL || !isdigit((int)tmpbuf[0])) {
return tmpbuf;
diff --git a/main/main.c b/main/main.c
index e56d70940e..8e6cd90fe8 100644
--- a/main/main.c
+++ b/main/main.c
@@ -100,8 +100,13 @@ PHPAPI int core_globals_id;
*/
static PHP_INI_MH(OnSetPrecision)
{
- EG(precision) = atoi(new_value);
- return SUCCESS;
+ int i = atoi(new_value);
+ if (i >= 0) {
+ EG(precision) = i;
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
}
/* }}} */