diff options
author | vladyslavstartsev <vladyslavstartsev@gmail.com> | 2019-04-30 17:33:04 +0300 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-14 15:04:21 +0200 |
commit | a07d422ade48e875740a6733543179e7f67a573e (patch) | |
tree | 8c6e68b23335d831c6ae5a1e203d080cd10bdc59 /ext/bcmath/bcmath.c | |
parent | 3f19f5112a7be3e4aa7ab1704d25de54645be373 (diff) | |
download | php-git-a07d422ade48e875740a6733543179e7f67a573e.tar.gz |
Warn about non well-formed arguments in bcmath
Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
Co-Authored-By: Christoph M. Becker <cmbecker69@gmx.de>
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r-- | ext/bcmath/bcmath.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 33be8465c2..ecfce4f54d 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -198,11 +198,15 @@ static void php_str2num(bc_num *num, char *str) char *p; if (!(p = strchr(str, '.'))) { - bc_str2num(num, str, 0); + if (!bc_str2num(num, str, 0)) { + php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed"); + } return; } - bc_str2num(num, str, strlen(p+1)); + if (!bc_str2num(num, str, strlen(p+1))) { + php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed"); + } } /* }}} */ @@ -527,8 +531,12 @@ PHP_FUNCTION(bccomp) bc_init_num(&first); bc_init_num(&second); - bc_str2num(&first, ZSTR_VAL(left), scale); - bc_str2num(&second, ZSTR_VAL(right), scale); + if (!bc_str2num(&first, ZSTR_VAL(left), scale)) { + php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed"); + } + if (!bc_str2num(&second, ZSTR_VAL(right), scale)) { + php_error_docref(NULL, E_WARNING, "bcmath function argument is not well-formed"); + } RETVAL_LONG(bc_compare(first, second)); bc_free_num(&first); |