php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch base-convert-notice for Math related Bug #61740

Patch version 2016-06-30 12:10 UTC

Return to Bug #61740 | Download this patch
Patch Revisions:

Developer: cmb@php.net

 ext/standard/math.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ext/standard/math.c b/ext/standard/math.c
index 0a408d0..eb0f7d6 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -1020,6 +1020,7 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
 	char c, *s;
 	zend_long cutoff;
 	int cutlim;
+	zend_bool invalid_chars_ignored = 0;
 
 	if (Z_TYPE_P(arg) != IS_STRING || base < 2 || base > 36) {
 		return FAILURE;
@@ -1040,11 +1041,15 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
 			c -= 'A' - 10;
 		else if (c >= 'a' && c <= 'z')
 			c -= 'a' - 10;
-		else
+		else {
+			invalid_chars_ignored |= 1;
 			continue;
+		}
 
-		if (c >= base)
+		if (c >= base) {
+			invalid_chars_ignored |= 1;
 			continue;
+		}
 
 		switch (mode) {
 		case 0: /* Integer */
@@ -1060,6 +1065,10 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
 			fnum = fnum * base + c;
 		}
 	}
+	
+	if (invalid_chars_ignored) {
+		php_error_docref(NULL, E_NOTICE, "Invalid characters ignored");
+	}
 
 	if (mode == 1) {
 		ZVAL_DOUBLE(ret, fnum);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 00:01:32 2024 UTC