rasmus Wed Apr 2 18:50:41 2003 EDT Modified files: (Branch: PHP_4_3) /php4 TODO_SEGFAULTS /php4/ext/bcmath bcmath.c Log: Negative precision makes no sense, so check for that, but let the memory manager error out on huge non-negative precision args Index: php4/TODO_SEGFAULTS diff -u php4/TODO_SEGFAULTS:1.1.2.10 php4/TODO_SEGFAULTS:1.1.2.11 --- php4/TODO_SEGFAULTS:1.1.2.10 Wed Apr 2 18:09:39 2003 +++ php4/TODO_SEGFAULTS Wed Apr 2 18:50:40 2003 @@ -12,10 +12,10 @@ str_repeat (Ilia) setlocale (Rasmus) unregister_tick_function (Rasmus) + bcsub (Rasmus) Open: - bcsub (1) mb_ereg (2) mb_ereg_match (2) mb_eregi (2) @@ -24,9 +24,6 @@ xml_parser_create (Unable to reproduce - Rasmus) Notes: - -(1) appears, when bcadd, bcmod, bcmul, bcscale, bcsqrt have been tested - prior to it. does not segfault when tested alone. (2) sometimes, mb_ereg passes the test, although a subsequent mbereg will cause a segfault. Probably something in-between screws up the engine. Index: php4/ext/bcmath/bcmath.c diff -u php4/ext/bcmath/bcmath.c:1.39.4.6 php4/ext/bcmath/bcmath.c:1.39.4.7 --- php4/ext/bcmath/bcmath.c:1.39.4.6 Thu Feb 6 17:23:36 2003 +++ php4/ext/bcmath/bcmath.c Wed Apr 2 18:50:41 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: bcmath.c,v 1.39.4.6 2003/02/06 22:23:36 pollita Exp $ */ +/* $Id: bcmath.c,v 1.39.4.7 2003/04/02 23:50:41 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -96,7 +96,7 @@ if (cfg_get_long("bcmath.scale", &bc_precision)==FAILURE) { bc_precision=0; } - + if(bc_precision<0) bc_precision=0; bc_init_numbers(TSRMLS_C); return SUCCESS; @@ -144,7 +144,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -189,7 +189,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -234,7 +234,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -279,7 +279,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -371,7 +371,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -416,7 +416,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -458,7 +458,7 @@ WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -492,7 +492,8 @@ } convert_to_long_ex(new_scale); - bc_precision = Z_LVAL_PP(new_scale); + bc_precision = (Z_LVAL_PP(new_scale)<0) ? 0 : Z_LVAL_PP(new_scale); + RETURN_TRUE; } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php