fix signed/unsigned mismatch

This commit is contained in:
Anatol Belski 2014-09-16 23:25:18 +02:00
parent f2e728616c
commit dda7a01480

View File

@ -2029,7 +2029,7 @@ PHP_FUNCTION(strripos)
/* Single character search can shortcut memcmps
Can also avoid tolower emallocs */
if (offset >= 0) {
if (offset > haystack->len) {
if ((size_t)offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
@ -2037,7 +2037,7 @@ PHP_FUNCTION(strripos)
e = haystack->val + haystack->len - 1;
} else {
p = haystack->val;
if (offset < -INT_MAX || -offset > haystack->len) {
if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
@ -2060,7 +2060,7 @@ PHP_FUNCTION(strripos)
php_strtolower(haystack_dup, haystack->len);
if (offset >= 0) {
if (offset > haystack->len) {
if ((size_t)offset > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
@ -2069,14 +2069,14 @@ PHP_FUNCTION(strripos)
p = haystack_dup + offset;
e = haystack_dup + haystack->len - needle_len;
} else {
if (offset < -INT_MAX || -offset > haystack->len) {
if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
p = haystack_dup;
if (needle_len > -offset) {
if (needle_len > (size_t)(-offset)) {
e = haystack_dup + haystack->len - needle_len;
} else {
e = haystack_dup + haystack->len + offset;
@ -2200,7 +2200,7 @@ PHP_FUNCTION(chunk_split)
RETURN_FALSE;
}
if (chunklen > str->len) {
if ((size_t)chunklen > str->len) {
/* to maintain BC, we must return original string + ending */
result = zend_string_alloc(endlen + str->len, 0);
memcpy(result->val, str->val, str->len);
@ -2213,7 +2213,7 @@ PHP_FUNCTION(chunk_split)
RETURN_EMPTY_STRING();
}
result = php_chunk_split(str->val, str->len, end, endlen, chunklen);
result = php_chunk_split(str->val, str->len, end, endlen, (size_t)chunklen);
if (result) {
RETURN_STR(result);
@ -2245,7 +2245,7 @@ PHP_FUNCTION(substr)
#endif
if (argc > 2) {
if ((l < 0 && -l > str->len)) {
if ((l < 0 && (size_t)(-l) > str->len)) {
RETURN_FALSE;
} else if (l > (zend_long)str->len) {
l = str->len;
@ -3797,7 +3797,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
zval result;
zend_string *string_key;
zend_ulong num_key;
zend_long count = 0;
size_t count = 0;
int argc = ZEND_NUM_ARGS();
#ifndef FAST_ZPP
@ -5002,7 +5002,7 @@ PHP_FUNCTION(substr_count)
RETURN_FALSE;
}
if (offset > haystack_len) {
if ((size_t)offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value " ZEND_LONG_FMT " exceeds string length", offset);
RETURN_FALSE;
}
@ -5061,7 +5061,7 @@ PHP_FUNCTION(str_pad)
/* If resulting string turns out to be shorter than input string,
we simply copy the input and return. */
if (pad_length < 0 || pad_length <= input->len) {
if (pad_length < 0 || (size_t)pad_length <= input->len) {
RETURN_STRINGL(input->val, input->len);
}
@ -5350,7 +5350,7 @@ PHP_FUNCTION(str_split)
}
if (0 == str->len || split_length >= str->len) {
if (0 == str->len || (size_t)split_length >= str->len) {
array_init_size(return_value, 1);
add_next_index_stringl(return_value, str->val, str->len);
return;
@ -5427,7 +5427,7 @@ PHP_FUNCTION(substr_compare)
offset = (offset < 0) ? 0 : offset;
}
if (offset >= s1->len) {
if ((size_t)offset >= s1->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}