summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-04-05 11:36:13 +0000
committerAntony Dovgal <tony2001@php.net>2006-04-05 11:36:13 +0000
commite25a1dccac9cbed2cb8d8860519e2ab49e25d30a (patch)
tree6b4fb4a001cb00f4ebad9f87e338be7cdcd85f6c /Zend/zend_builtin_functions.c
parentf0cf877a81b769aa73f81d9b6c0ebec5f85185c2 (diff)
downloadphp-git-e25a1dccac9cbed2cb8d8860519e2ab49e25d30a.tar.gz
fix #36944 (strncmp & strncasecmp do not return false on negative string length)
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 07e5bf6ad1..f4a432d028 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -314,6 +314,12 @@ ZEND_FUNCTION(strncmp)
convert_to_string_ex(s1);
convert_to_string_ex(s2);
convert_to_long_ex(s3);
+
+ if (Z_LVAL_PP(s3) < 0) {
+ zend_error(E_WARNING, "Length must be greater than or equal to 0");
+ RETURN_FALSE;
+ }
+
RETURN_LONG(zend_binary_zval_strncmp(*s1, *s2, *s3));
}
/* }}} */
@@ -347,6 +353,12 @@ ZEND_FUNCTION(strncasecmp)
convert_to_string_ex(s1);
convert_to_string_ex(s2);
convert_to_long_ex(s3);
+
+ if (Z_LVAL_PP(s3) < 0) {
+ zend_error(E_WARNING, "Length must be greater than or equal to 0");
+ RETURN_FALSE;
+ }
+
RETURN_LONG(zend_binary_zval_strncasecmp(*s1, *s2, *s3));
}
/* }}} */