cvs: php4(PHP_4_3) /ext/standard array.c basic_functions.c file.c filestat.c formatted_print.c scanf.c

From: Date: Wed, 23 Apr 2003 02:37:29 +0000
Subject: cvs: php4(PHP_4_3) /ext/standard array.c basic_functions.c file.c filestat.c formatted_print.c scanf.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20435@lists.php.net to get a copy of this message
iliaa Tue Apr 22 22:37:29 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard scanf.c formatted_print.c filestat.c file.c basic_functions.c array.c Log: emalloc -> safe_emalloc

Index: php4/ext/standard/scanf.c diff -u php4/ext/standard/scanf.c:1.16.4.4 php4/ext/standard/scanf.c:1.16.4.5 --- php4/ext/standard/scanf.c:1.16.4.4 Sat Jan 18 16:20:47 2003 +++ php4/ext/standard/scanf.c Tue Apr 22 22:37:29 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: scanf.c,v 1.16.4.4 2003/01/18 21:20:47 moriyoshi Exp $ */ +/* $Id: scanf.c,v 1.16.4.5 2003/04/23 02:37:29 iliaa Exp $ */ /* scanf.c -- @@ -175,9 +175,9 @@ ch = end++; } - cset->chars = (char *) emalloc(sizeof(char) * (end - format - 1)); + cset->chars = (char *) safe_emalloc(sizeof(char), (end - format - 1), 0); if (nranges > 0) { - cset->ranges = (struct Range *) emalloc(sizeof(struct Range)*nranges); + cset->ranges = (struct Range *) safe_emalloc(sizeof(struct Range), nranges, 0); } else { cset->ranges = NULL; } @@ -337,7 +337,7 @@ */ if (numVars > nspace) { - nassign = (int*)emalloc(sizeof(int) * numVars); + nassign = (int*)safe_emalloc(sizeof(int), numVars, 0); nspace = numVars; } for (i = 0; i < nspace; i++) { @@ -513,7 +513,7 @@ nspace += STATIC_LIST_SIZE; } if (nassign == staticAssign) { - nassign = (void *)emalloc(nspace * sizeof(int)); + nassign = (void *)safe_emalloc(nspace, sizeof(int), 0); for (i = 0; i < STATIC_LIST_SIZE; ++i) { nassign[i] = staticAssign[i]; } Index: php4/ext/standard/formatted_print.c diff -u php4/ext/standard/formatted_print.c:1.59.2.3 php4/ext/standard/formatted_print.c:1.59.2.4 --- php4/ext/standard/formatted_print.c:1.59.2.3 Sat Feb 15 10:59:13 2003 +++ php4/ext/standard/formatted_print.c Tue Apr 22 22:37:29 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.59.2.3 2003/02/15 15:59:13 moriyoshi Exp $ */ +/* $Id: formatted_print.c,v 1.59.2.4 2003/04/23 02:37:29 iliaa Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -474,7 +474,7 @@ SEPARATE_ZVAL(array); convert_to_array_ex(array); argc = 1 + zend_hash_num_elements(Z_ARRVAL_PP(array)); - args = (zval ***)emalloc(argc * sizeof(zval *)); + args = (zval ***)safe_emalloc(argc, sizeof(zval *), 0); args[0] = z_format; for (zend_hash_internal_pointer_reset(Z_ARRVAL_PP(array)); zend_hash_get_current_data(Z_ARRVAL_PP(array), (void **)&args[i++]) == SUCCESS; @@ -484,7 +484,7 @@ WRONG_PARAM_COUNT_WITH_RETVAL(NULL); } - args = (zval ***)emalloc(argc * sizeof(zval *)); + args = (zval ***)safe_emalloc(argc, sizeof(zval *), 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); Index: php4/ext/standard/filestat.c diff -u php4/ext/standard/filestat.c:1.112.2.5 php4/ext/standard/filestat.c:1.112.2.6 --- php4/ext/standard/filestat.c:1.112.2.5 Thu Feb 27 15:38:22 2003 +++ php4/ext/standard/filestat.c Tue Apr 22 22:37:29 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.112.2.5 2003/02/27 20:38:22 iliaa Exp $ */ +/* $Id: filestat.c,v 1.112.2.6 2003/04/23 02:37:29 iliaa Exp $ */ #include "php.h" #include "safe_mode.h" @@ -647,7 +647,7 @@ groups = getgroups(0, NULL); if(groups) { - gids=(gid_t *)emalloc(groups*sizeof(gid_t)); + gids=(gid_t *)safe_emalloc(groups, sizeof(gid_t), 0); n=getgroups(groups, gids); for(i=0;i<n;i++){ if(BG(sb).st_gid==gids[i]) { Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.279.2.15 php4/ext/standard/file.c:1.279.2.16 --- php4/ext/standard/file.c:1.279.2.15 Tue Apr 1 02:53:05 2003 +++ php4/ext/standard/file.c Tue Apr 22 22:37:29 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.279.2.15 2003/04/01 07:53:05 sas Exp $ */ +/* $Id: file.c,v 1.279.2.16 2003/04/23 02:37:29 iliaa Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1429,7 +1429,7 @@ RETURN_FALSE; } - buf = emalloc(sizeof(char) * (len + 1)); + buf = safe_emalloc(sizeof(char), (len + 1), 0); /*needed because recv doesnt set null char at end*/ memset(buf, 0, len + 1); @@ -1463,7 +1463,7 @@ if (argCount < 2) { WRONG_PARAM_COUNT; } - args = (zval ***)emalloc(argCount * sizeof(zval **)); + args = (zval ***)safe_emalloc(argCount, sizeof(zval **), 0); if (!args || (zend_get_parameters_array_ex(argCount, args) == FAILURE)) { efree( args ); WRONG_PARAM_COUNT; Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.543.2.12 php4/ext/standard/basic_functions.c:1.543.2.13 --- php4/ext/standard/basic_functions.c:1.543.2.12 Thu Apr 3 13:10:41 2003 +++ php4/ext/standard/basic_functions.c Tue Apr 22 22:37:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.543.2.12 2003/04/03 18:10:41 sas Exp $ */ +/* $Id: basic_functions.c,v 1.543.2.13 2003/04/23 02:37:29 iliaa Exp $ */ #include "php.h" #include "php_streams.h" @@ -1434,7 +1434,7 @@ * Attempt to allocate enough memory to hold all of the arguments * and a trailing NULL */ - if ((argv = (char **) emalloc((argc + 1) * sizeof(char *))) == NULL) { + if ((argv = (char **) safe_emalloc(sizeof(char *), (argc + 1), 0)) == NULL) { RETURN_FALSE; } @@ -1802,7 +1802,7 @@ WRONG_PARAM_COUNT; } - params = emalloc(sizeof(zval **) * argc); + params = safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, params) == FAILURE) { efree(params); @@ -1876,7 +1876,7 @@ func_params_ht = Z_ARRVAL_PP(params); count = zend_hash_num_elements(func_params_ht); - func_params = emalloc(sizeof(zval **) * count); + func_params = safe_emalloc(sizeof(zval **), count, 0); for (zend_hash_internal_pointer_reset(func_params_ht); zend_hash_get_current_data(func_params_ht, (void **) &func_params[current]) == SUCCESS; @@ -1911,7 +1911,7 @@ if (arg_count < 2) { WRONG_PARAM_COUNT; } - params = (zval ***) emalloc(sizeof(zval **) * arg_count); + params = (zval ***) safe_emalloc(sizeof(zval **), arg_count, 0); if (zend_get_parameters_array_ex(arg_count, params) == FAILURE) { efree(params); @@ -1961,7 +1961,7 @@ params_ar = HASH_OF(*params); num_elems = zend_hash_num_elements(params_ar); - method_args = (zval ***) emalloc(sizeof(zval **) *num_elems); + method_args = (zval ***) safe_emalloc(sizeof(zval **), num_elems, 0); for (zend_hash_internal_pointer_reset(params_ar); zend_hash_get_current_data(params_ar, (void **) &(method_args[element])) == SUCCESS; @@ -2107,7 +2107,7 @@ WRONG_PARAM_COUNT; } - shutdown_function_entry.arguments = (pval **) emalloc(sizeof(pval *) *shutdown_function_entry.arg_count); + shutdown_function_entry.arguments = (pval **) safe_emalloc(sizeof(pval *), shutdown_function_entry.arg_count, 0); if (zend_get_parameters_array(ht, shutdown_function_entry.arg_count, shutdown_function_entry.arguments) == FAILURE) { RETURN_FALSE; @@ -2643,7 +2643,7 @@ WRONG_PARAM_COUNT; } - tick_fe.arguments = (zval **) emalloc(sizeof(zval *) * tick_fe.arg_count); + tick_fe.arguments = (zval **) safe_emalloc(sizeof(zval *), tick_fe.arg_count, 0); if (zend_get_parameters_array(ht, tick_fe.arg_count, tick_fe.arguments) == FAILURE) { RETURN_FALSE; Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.199.2.16 php4/ext/standard/array.c:1.199.2.17 --- php4/ext/standard/array.c:1.199.2.16 Wed Apr 16 18:57:15 2003 +++ php4/ext/standard/array.c Tue Apr 22 22:37:29 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.199.2.16 2003/04/16 22:57:15 moriyoshi Exp $ */ +/* $Id: array.c,v 1.199.2.17 2003/04/23 02:37:29 iliaa Exp $ */ #include "php.h" #include "php_ini.h" @@ -865,7 +865,7 @@ RETURN_FALSE; } } else { - pval ***args = (pval ***) emalloc(sizeof(pval **)*ZEND_NUM_ARGS()); + pval ***args = (pval ***) safe_emalloc(sizeof(pval **), ZEND_NUM_ARGS(), 0); pval **min, result; int i; @@ -917,7 +917,7 @@ RETURN_FALSE; } } else { - pval ***args = (pval ***) emalloc(sizeof(pval **)*ZEND_NUM_ARGS()); + pval ***args = (pval ***) safe_emalloc(sizeof(pval **), ZEND_NUM_ARGS(), 0); pval **max, result; int i; @@ -1345,7 +1345,7 @@ zval ***args; /* function arguments array */ int i; - args = (zval ***)emalloc(ZEND_NUM_ARGS() * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0); if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { efree(args); @@ -1474,7 +1474,7 @@ return; } - elems = (Bucket **)emalloc(n_elems * sizeof(Bucket *)); + elems = (Bucket **)safe_emalloc(sizeof(Bucket *), n_elems, 0); hash = Z_ARRVAL_P(array); n_left = n_elems; @@ -1652,7 +1652,7 @@ } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -1774,7 +1774,7 @@ } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -1824,7 +1824,7 @@ } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -1854,7 +1854,7 @@ /* Create the array of replacement elements */ repl_num = zend_hash_num_elements(Z_ARRVAL_PP(args[3])); - repl = (zval ***)emalloc(repl_num * sizeof(zval **)); + repl = (zval ***)safe_emalloc(sizeof(zval **), repl_num, 0); for (p=Z_ARRVAL_PP(args[3])->pListHead, i=0; p; p=p->pListNext, i++) { repl[i] = ((zval **)p->pData); } @@ -2039,7 +2039,7 @@ } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -2343,7 +2343,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may only pad up to 1048576 elements at a time"); RETURN_FALSE; } - pads = (zval ***)emalloc(num_pads * sizeof(zval **)); + pads = (zval ***)safe_emalloc(sizeof(zval **), num_pads, 0); for (i = 0; i < num_pads; i++) pads[i] = pad_value; @@ -2547,14 +2547,14 @@ WRONG_PARAM_COUNT; } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; } /* for each argument, create and sort list with pointers to the hash buckets */ - lists = (Bucket ***)emalloc(argc * sizeof(Bucket **)); - ptrs = (Bucket ***)emalloc(argc * sizeof(Bucket **)); + lists = (Bucket ***)safe_emalloc(sizeof(Bucket **), argc, 0); + ptrs = (Bucket ***)safe_emalloc(sizeof(Bucket **), argc, 0); set_compare_func(SORT_STRING TSRMLS_CC); for (i=0; i<argc; i++) { if (Z_TYPE_PP(args[i]) != IS_ARRAY) { @@ -2695,14 +2695,14 @@ WRONG_PARAM_COUNT; } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; } /* for each argument, create and sort list with pointers to the hash buckets */ - lists = (Bucket ***)emalloc(argc * sizeof(Bucket **)); - ptrs = (Bucket ***)emalloc(argc * sizeof(Bucket **)); + lists = (Bucket ***)safe_emalloc(sizeof(Bucket **), argc, 0); + ptrs = (Bucket ***)safe_emalloc(sizeof(Bucket **), argc, 0); set_compare_func(SORT_STRING TSRMLS_CC); for (i = 0; i < argc; i++) { if (Z_TYPE_PP(args[i]) != IS_ARRAY) { @@ -2888,7 +2888,7 @@ } /* Allocate arguments array and get the arguments, checking for errors. */ - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -2990,9 +2990,9 @@ of the input arrays + 1. The last column is NULL to indicate the end of the row. */ - indirect = (Bucket ***)emalloc(array_size * sizeof(Bucket **)); + indirect = (Bucket ***)safe_emalloc(sizeof(Bucket **), array_size, 0); for (i = 0; i < array_size; i++) - indirect[i] = (Bucket **)emalloc((num_arrays+1) * sizeof(Bucket *)); + indirect[i] = (Bucket **)safe_emalloc(sizeof(Bucket *), (num_arrays+1), 0); for (i = 0; i < num_arrays; i++) { k = 0; @@ -3329,7 +3329,7 @@ WRONG_PARAM_COUNT; } - args = (zval ***)emalloc(ZEND_NUM_ARGS() * sizeof(zval **)); + args = (zval ***)safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0); if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -3349,8 +3349,8 @@ } /* Allocate array sizes and iterators. */ - array_len = (int*)emalloc((ZEND_NUM_ARGS()-1) * sizeof(int)); - array_pos = (HashPosition*)emalloc((ZEND_NUM_ARGS()-1) * sizeof(HashPosition)); + array_len = (int*)safe_emalloc(sizeof(int), (ZEND_NUM_ARGS()-1), 0); + array_pos = (HashPosition*)safe_emalloc(sizeof(HashPosition), (ZEND_NUM_ARGS()-1), 0); /* Check that arrays are indeed arrays and calculate maximum size. */ for (i = 0; i < ZEND_NUM_ARGS()-1; i++) { @@ -3378,7 +3378,7 @@ } array_init(return_value); - params = (zval ***)emalloc((ZEND_NUM_ARGS()-1) * sizeof(zval **)); + params = (zval ***)safe_emalloc(sizeof(zval **), (ZEND_NUM_ARGS()-1), 0); MAKE_STD_ZVAL(null); ZVAL_NULL(null);
« previous php.cvs (#20435) next »