mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
MF51: fix #36944 (strncmp & strncasecmp do not return false on negative string length)
This commit is contained in:
parent
d81161af49
commit
3305bba32b
1 changed files with 12 additions and 0 deletions
|
@ -333,6 +333,12 @@ ZEND_FUNCTION(strncmp)
|
||||||
&s1_type, &s2, &s2_len, &s2_type, &count) == FAILURE) {
|
&s1_type, &s2, &s2_len, &s2_type, &count) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count < 0) {
|
||||||
|
zend_error(E_WARNING, "Length must be greater than or equal to 0");
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (s1_type == IS_UNICODE) {
|
if (s1_type == IS_UNICODE) {
|
||||||
RETURN_LONG(zend_u_binary_strncmp(s1, s1_len, s2, s2_len, count));
|
RETURN_LONG(zend_u_binary_strncmp(s1, s1_len, s2, s2_len, count));
|
||||||
} else {
|
} else {
|
||||||
|
@ -376,6 +382,12 @@ ZEND_FUNCTION(strncasecmp)
|
||||||
&s1_type, &s2, &s2_len, &s2_type, &len) == FAILURE) {
|
&s1_type, &s2, &s2_len, &s2_type, &len) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len < 0) {
|
||||||
|
zend_error(E_WARNING, "Length must be greater than or equal to 0");
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (s1_type == IS_UNICODE) {
|
if (s1_type == IS_UNICODE) {
|
||||||
RETURN_LONG(zend_u_binary_strncasecmp(s1, s1_len, s2, s2_len, len));
|
RETURN_LONG(zend_u_binary_strncasecmp(s1, s1_len, s2, s2_len, len));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue