Uh oh!
There was an error while loading. Please reload this page.
made scale argument of bcmath functions non-negative integer - #5455
made scale argument of bcmath functions non-negative integer#5455vladysta wants to merge 1 commit into
Conversation
ebf7e7c to
6dcbac8CompareUh oh!
There was an error while loading. Please reload this page.
6dcbac8 to
5fddc27Comparevladysta
commented
Apr 26, 2020
Can't add reviewers, so I'm just adding you to this message @nikic@kocsismate |
Uh oh!
There was an error while loading. Please reload this page.
cmb69
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Please address my inline comments.
Also, I think it is worthwhile to change bc_precision to int as well, and to introduce a custom validator, something like:
ext/bcmath/bcmath.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 38fa4d033d..35d1bc92f6 100644
--- a/ext/bcmath/bcmath.c+++ b/ext/bcmath/bcmath.c@@ -57,9 +57,32 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_GET_MODULE(bcmath)
#endif
+ZEND_INI_MH(OnUpdateScale)+{+ int *p;+ zend_long tmp;+#ifndef ZTS+ char *base = (char *) mh_arg2;+#else+ char *base;++ base = (char *) ts_resource(*((int *) mh_arg2));+#endif++ tmp = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));+ if (tmp < 0 || tmp > INT_MAX) {+ return FAILURE;+ }++ p = (int *) (base+(size_t) mh_arg1);+ *p = (int) tmp;++ return SUCCESS;+}+
/* {{{ PHP_INI */
PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("bcmath.scale", "0", PHP_INI_ALL, OnUpdateLongGEZero, bc_precision, zend_bcmath_globals, bcmath_globals)+ STD_PHP_INI_ENTRY("bcmath.scale", "0", PHP_INI_ALL, OnUpdateScale, bc_precision, zend_bcmath_globals, bcmath_globals)
PHP_INI_END()
/* }}} */
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a20c9bd to
263d335Comparevladysta
commented
Apr 26, 2020
Now the scale INI is not set. https://travis-ci.org/github/php/php-src/jobs/679741601#L2251 Can you help, to say what is wrong? |
cmb69
commented
Apr 26, 2020
Oh, sorry, my patch was incomplete. Need this as well: ext/bcmath/php_bcmath.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ext/bcmath/php_bcmath.h b/ext/bcmath/php_bcmath.h
index bafaf29e7a..c7a8a85d73 100644
--- a/ext/bcmath/php_bcmath.h+++ b/ext/bcmath/php_bcmath.h@@ -33,7 +33,7 @@ ZEND_BEGIN_MODULE_GLOBALS(bcmath)
bc_num _zero_;
bc_num _one_;
bc_num _two_;
- zend_long bc_precision;+ int bc_precision;
ZEND_END_MODULE_GLOBALS(bcmath)
#if defined(ZTS) && defined(COMPILE_DL_BCMATH) |
263d335 to
0022353CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- code styles (spaces -> tabs) - add custom ini setting validator (OnUpdateScale)
0022353 to
c167235Compare
If you think I should make RFC, I will. From my POV it's just bugs and next (8) release can break things a little bit, so I'm making it more strict.
The only thing that bothers me is
ext/bcmath/tests/bug60377.phpt. I did print out thebut it says
integer. But internally it, somehow breaks and makes scale0, this haven't worked before (I mean I haven't break the behavior where634314234334311casts to0) I have tried to do this before patchand got
0.I may try to fix it, but I think