summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/iconv/iconv.c6
-rw-r--r--ext/json/utf8_decode.h2
-rw-r--r--ext/mbstring/mbstring.c2
-rw-r--r--ext/mbstring/php_mbregex.c4
-rw-r--r--ext/mysqlnd/mysqlnd.c2
-rw-r--r--ext/opcache/Optimizer/compact_literals.c4
-rw-r--r--ext/pdo/pdo_sql_parser.c2
-rw-r--r--ext/session/session.c3
-rw-r--r--ext/spl/spl_directory.c7
-rw-r--r--ext/spl/spl_dllist.c2
-rw-r--r--ext/standard/array.c11
-rw-r--r--ext/standard/basic_functions.c3
-rw-r--r--ext/standard/info.c2
-rw-r--r--ext/standard/string.c55
-rw-r--r--ext/zip/lib/zip_set_name.c2
-rw-r--r--ext/zlib/zlib_filter.c2
16 files changed, 62 insertions, 47 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index ac2374c6a3..490a92618d 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -824,16 +824,16 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
}
}
- if(len > (zend_long)total_len) {
+ if((size_t)len > total_len) {
len = total_len;
}
- if (offset >= (zend_long)total_len) {
+ if ((size_t)offset >= total_len) {
return PHP_ICONV_ERR_SUCCESS;
}
- if ((offset + len) > (zend_long)total_len ) {
+ if ((size_t)(offset + len) > total_len ) {
/* trying to compute the length */
len = total_len - offset;
}
diff --git a/ext/json/utf8_decode.h b/ext/json/utf8_decode.h
index cc0fc79f6c..0908edd2d4 100644
--- a/ext/json/utf8_decode.h
+++ b/ext/json/utf8_decode.h
@@ -5,8 +5,8 @@
typedef struct json_utf8_decode
{
- int the_index;
char *the_input;
+ int the_index;
int the_length;
int the_char;
int the_byte;
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 212c8d013f..615381e6c4 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -2963,7 +2963,7 @@ PHP_FUNCTION(mb_strimwidth)
string.val = (unsigned char *)str;
string.len = str_len;
- if (from < 0 || from > str_len) {
+ if (from < 0 || (size_t)from > str_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Start position is out of range");
RETURN_FALSE;
}
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 9628ee2526..864d50a5ce 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1081,7 +1081,7 @@ PHP_FUNCTION(mb_split)
err = 0;
regs = onig_region_new();
/* churn through str, generating array entries as we go */
- while (count != 0 && (pos - (OnigUChar *)string) < string_len) {
+ while (count != 0 && (pos - (OnigUChar *)string) < (ptrdiff_t)string_len) {
int beg, end;
err = onig_search(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), pos, (OnigUChar *)(string + string_len), regs, 0);
if (err < 0) {
@@ -1403,7 +1403,7 @@ PHP_FUNCTION(mb_ereg_search_setpos)
return;
}
- if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN(MBREX(search_str)))) {
+ if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && (size_t)position >= Z_STRLEN(MBREX(search_str)))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range");
MBREX(search_pos) = 0;
RETURN_FALSE;
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index 74a8b721f2..20972f64be 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -2798,7 +2798,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi
smart_str_appendl(&tmp_str, "WITH CONSISTENT SNAPSHOT", sizeof("WITH CONSISTENT SNAPSHOT") - 1);
}
if (mode & (TRANS_START_READ_WRITE | TRANS_START_READ_ONLY)) {
- unsigned long server_version = conn->m->get_server_version(conn TSRMLS_CC);
+ zend_ulong server_version = conn->m->get_server_version(conn TSRMLS_CC);
if (server_version < 50605L) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This server version doesn't support 'READ WRITE' and 'READ ONLY'. Minimum 5.6.5 is required");
smart_str_free(&tmp_str);
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index 28e7a11314..091437e119 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -40,6 +40,7 @@
#define LITERAL_STATIC_PROPERTY 0x0700
#define LITERAL_METHOD 0x0800
#define LITERAL_PROPERTY 0x0900
+#define LITERAL_GLOBAL 0x0A00
#define LITERAL_EX_CLASS 0x4000
#define LITERAL_EX_OBJ 0x2000
@@ -278,6 +279,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
}
}
break;
+ case ZEND_BIND_GLOBAL:
+ LITERAL_INFO(opline->op2.constant, LITERAL_GLOBAL, 0, 1, 1);
+ break;
default:
if (ZEND_OP1_TYPE(opline) == IS_CONST) {
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1, 0, 1);
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index 0db82c6068..11b91e778f 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -406,10 +406,10 @@ yy45:
struct placeholder {
char *pos;
+ char *quoted; /* quoted value */
int len;
int bindno;
int qlen; /* quoted length of value */
- char *quoted; /* quoted value */
int freeq;
struct placeholder *next;
};
diff --git a/ext/session/session.c b/ext/session/session.c
index de8cf23310..63463d487b 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1268,7 +1268,8 @@ static void php_session_remove_cookie(TSRMLS_D) {
zend_llist_element *current;
char *session_cookie;
zend_string *e_session_name;
- int session_cookie_len, len = sizeof("Set-Cookie")-1;
+ int session_cookie_len;
+ uint len = sizeof("Set-Cookie")-1;
e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)));
spprintf(&session_cookie, 0, "Set-Cookie: %s=", e_session_name->val);
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 0694e8f335..293be0b0dd 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2883,7 +2883,12 @@ SPL_METHOD(SplFileObject, fwrite)
}
if (ZEND_NUM_ARGS() > 1) {
- str_len = MAX(0, MIN(length, str_len));
+ if (length >= 0) {
+ str_len = MAX(0, MIN((size_t)length, str_len));
+ } else {
+ /* Negative length given, nothing to write */
+ str_len = 0;
+ }
}
if (!str_len) {
RETURN_LONG(0);
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index e02b9b2e83..1bd4bf49d5 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -101,8 +101,8 @@ struct _spl_dllist_object {
/* define an overloaded iterator structure */
struct _spl_dllist_it {
zend_user_iterator intern;
- int traverse_position;
spl_ptr_llist_element *traverse_pointer;
+ int traverse_position;
int flags;
};
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 09aaddfbf5..a417925528 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1528,7 +1528,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
PHP_FUNCTION(compact)
{
zval *args = NULL; /* function arguments array */
- int num_args, i;
+ uint32_t num_args, i;
zend_array *symbol_table;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &num_args) == FAILURE) {
@@ -2085,7 +2085,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
zend_hash_rehash(Z_ARRVAL_P(stack));
}
}
- } else if (!key && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
+ } else if (!key && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= (zend_ulong)(Z_ARRVAL_P(stack)->nNextFreeElement - 1)) {
Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1;
}
@@ -3174,7 +3174,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
int arr_argc, i, c = 0;
uint idx;
Bucket **lists, *list, **ptrs, *p;
- int req_args;
+ uint32_t req_args;
char *param_spec;
zend_fcall_info fci1, fci2;
zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
@@ -3598,7 +3598,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
int arr_argc, i, c;
uint idx;
Bucket **lists, *list, **ptrs, *p;
- int req_args;
+ uint32_t req_args;
char *param_spec;
zend_fcall_info fci1, fci2;
zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
@@ -4423,7 +4423,8 @@ PHP_FUNCTION(array_map)
zval result;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
- int i, k, maxlen = 0;
+ int i;
+ uint32_t k, maxlen = 0;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!+", &fci, &fci_cache, &arrays, &n_arrays) == FAILURE) {
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index de4d71106b..53aec268b0 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4178,8 +4178,9 @@ static int parse_opts(char * opts, opt_struct ** result)
{
opt_struct * paras = NULL;
unsigned int i, count = 0;
+ unsigned int opts_len = (unsigned int)strlen(opts);
- for (i = 0; i < strlen(opts); i++) {
+ for (i = 0; i < opts_len; i++) {
if ((opts[i] >= 48 && opts[i] <= 57) ||
(opts[i] >= 65 && opts[i] <= 90) ||
(opts[i] >= 97 && opts[i] <= 122)
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 286ea5c2cb..e74772da39 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -219,7 +219,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
php_info_print(string_key->val);
}
} else {
- php_info_printf("%pd", num_key);
+ php_info_printf(ZEND_ULONG_FMT, num_key);
}
php_info_print("\"]");
if (!sapi_module.phpinfo_as_text) {
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 0c41249473..c01259b85e 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -780,7 +780,7 @@ static inline int php_charmask(unsigned char *input, size_t len, char *mask TSRM
*/
PHPAPI char *php_trim(char *c, size_t len, char *what, size_t what_len, zval *return_value, int mode TSRMLS_DC)
{
- register zend_long i;
+ register size_t i;
size_t trimmed = 0;
char mask[256];
@@ -802,12 +802,15 @@ PHPAPI char *php_trim(char *c, size_t len, char *what, size_t what_len, zval *re
c += trimmed;
}
if (mode & 2) {
- for (i = len - 1; i >= 0; i--) {
- if (mask[(unsigned char)c[i]]) {
- len--;
- } else {
- break;
- }
+ if (len > 0) {
+ i = len - 1;
+ do {
+ if (mask[(unsigned char)c[i]]) {
+ len--;
+ } else {
+ break;
+ }
+ } while (i-- != 0);
}
}
@@ -1810,7 +1813,7 @@ PHP_FUNCTION(strpos)
ZEND_PARSE_PARAMETERS_END();
#endif
- if (offset < 0 || offset > haystack->len) {
+ if (offset < 0 || (size_t)offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
@@ -1860,7 +1863,7 @@ PHP_FUNCTION(stripos)
return;
}
- if (offset < 0 || offset > haystack->len) {
+ if (offset < 0 || (size_t)offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
@@ -1948,20 +1951,20 @@ PHP_FUNCTION(strrpos)
}
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;
}
- p = haystack->val + offset;
+ p = haystack->val + (size_t)offset;
e = haystack->val + haystack->len - needle_len;
} else {
- 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;
}
p = haystack->val;
- if (needle_len > -offset) {
+ if (needle_len > (size_t)(-offset)) {
e = haystack->val + haystack->len - needle_len;
} else {
e = haystack->val + haystack->len + offset;
@@ -2026,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;
}
@@ -2034,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;
}
@@ -2057,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");
@@ -2066,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;
@@ -2197,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);
@@ -2210,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);
@@ -2242,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;
@@ -3794,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
@@ -4999,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;
}
@@ -5058,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);
}
@@ -5347,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;
@@ -5424,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;
}
diff --git a/ext/zip/lib/zip_set_name.c b/ext/zip/lib/zip_set_name.c
index 02fa1272d6..4793c54534 100644
--- a/ext/zip/lib/zip_set_name.c
+++ b/ext/zip/lib/zip_set_name.c
@@ -58,7 +58,7 @@ _zip_set_name(struct zip *za, zip_uint64_t idx, const char *name, zip_flags_t fl
return -1;
}
- if (name && strlen(name) > 0) {
+ if (name && name[0] != '\0') {
/* TODO: check for string too long */
if ((str=_zip_string_new((const zip_uint8_t *)name, (zip_uint16_t)strlen(name), flags, &za->error)) == NULL)
return -1;
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 53bc2e4269..29377d8e99 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -25,12 +25,12 @@
/* Passed as opaque in malloc callbacks */
typedef struct _php_zlib_filter_data {
- int persistent;
z_stream strm;
char *inbuf;
size_t inbuf_len;
char *outbuf;
size_t outbuf_len;
+ int persistent;
zend_bool finished;
} php_zlib_filter_data;