Commit: a7862de2db615f351fd746bd2fb87564b9631e73
Author: Anatol Belski <a...@php.net> Thu, 28 Nov 2013 17:16:25 +0100
Parents: fd7d31973ac0a50c415fae9acf891c52f9e4779f
Branches: str_size_and_int64
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=a7862de2db615f351fd746bd2fb87564b9631e73
Log:
fixed ext/filter
Changed paths:
M ext/filter/filter.c
M ext/filter/logical_filters.c
M ext/filter/php_filter.h
M ext/filter/sanitizing_filters.c
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index 12aebcf..d521486 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -77,7 +77,7 @@ static const filter_list_entry filter_list[] = {
#define PARSE_SESSION 6
#endif
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned
int val_len, unsigned int *new_val_len TSRMLS_DC);
+static unsigned int php_sapi_filter(int arg, char *var, char **val,
zend_str_size_uint val_len, zend_str_size_uint *new_val_len TSRMLS_DC);
static unsigned int php_sapi_filter_init(TSRMLS_D);
/* {{{ arginfo */
@@ -327,7 +327,7 @@ PHP_MINFO_FUNCTION(filter)
}
/* }}} */
-static filter_list_entry php_find_filter(long id) /* {{{ */
+static filter_list_entry php_find_filter(php_int_t id) /* {{{ */
{
int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
@@ -358,7 +358,7 @@ static unsigned int php_sapi_filter_init(TSRMLS_D)
return SUCCESS;
}
-static void php_zval_filter(zval **value, long filter, long flags, zval
*options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */
+static void php_zval_filter(zval **value, php_int_t filter, php_int_t flags,
zval *options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */
{
filter_list_entry filter_func;
@@ -404,7 +404,7 @@ static void php_zval_filter(zval **value, long filter, long
flags, zval *options
}
/* }}} */
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned
int val_len, unsigned int *new_val_len TSRMLS_DC) /* {{{ */
+static unsigned int php_sapi_filter(int arg, char *var, char **val,
zend_str_size_uint val_len, zend_str_size_uint *new_val_len TSRMLS_DC) /* {{{ */
{
zval new_var, raw_var;
zval *array_ptr = NULL, *orig_array_ptr = NULL;
@@ -449,7 +449,7 @@ static unsigned int php_sapi_filter(int arg, char *var,
char **val, unsigned int
if (array_ptr) {
/* Store the RAW variable internally */
- Z_STRLEN(raw_var) = val_len;
+ Z_STRSIZE(raw_var) = val_len;
Z_STRVAL(raw_var) = estrndup(*val, val_len);
Z_TYPE(raw_var) = IS_STRING;
@@ -458,7 +458,7 @@ static unsigned int php_sapi_filter(int arg, char *var,
char **val, unsigned int
if (val_len) {
/* Register mangled variable */
- Z_STRLEN(new_var) = val_len;
+ Z_STRSIZE(new_var) = val_len;
Z_TYPE(new_var) = IS_STRING;
if (IF_G(default_filter) != FILTER_UNSAFE_RAW) {
@@ -479,11 +479,11 @@ static unsigned int php_sapi_filter(int arg, char *var,
char **val, unsigned int
if (retval) {
if (new_val_len) {
- *new_val_len = Z_STRLEN(new_var);
+ *new_val_len = Z_STRSIZE(new_var);
}
efree(*val);
- if (Z_STRLEN(new_var)) {
- *val = estrndup(Z_STRVAL(new_var), Z_STRLEN(new_var));
+ if (Z_STRSIZE(new_var)) {
+ *val = estrndup(Z_STRVAL(new_var), Z_STRSIZE(new_var));
} else {
*val = estrdup("");
}
@@ -494,7 +494,7 @@ static unsigned int php_sapi_filter(int arg, char *var,
char **val, unsigned int
}
/* }}} */
-static void php_zval_filter_recursive(zval **value, long filter, long flags,
zval *options, char *charset, zend_bool copy TSRMLS_DC) /* {{{ */
+static void php_zval_filter_recursive(zval **value, php_int_t filter,
php_int_t flags, zval *options, char *charset, zend_bool copy TSRMLS_DC) /* {{{
*/
{
if (Z_TYPE_PP(value) == IS_ARRAY) {
zval **element;
@@ -523,7 +523,7 @@ static void php_zval_filter_recursive(zval **value, long
filter, long flags, zva
}
/* }}} */
-static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
+static zval *php_filter_get_storage(php_int_t arg TSRMLS_DC)/* {{{ */
{
zval *array_ptr = NULL;
@@ -569,12 +569,12 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/*
{{{ */
*/
PHP_FUNCTION(filter_has_var)
{
- long arg;
+ php_int_t arg;
char *var;
- int var_len;
+ zend_str_size_int var_len;
zval *array_ptr = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &arg, &var,
&var_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iS", &arg, &var,
&var_len) == FAILURE) {
RETURN_FALSE;
}
@@ -588,14 +588,14 @@ PHP_FUNCTION(filter_has_var)
}
/* }}} */
-static void php_filter_call(zval **filtered, long filter, zval **filter_args,
const int copy, long filter_flags TSRMLS_DC) /* {{{ */
+static void php_filter_call(zval **filtered, php_int_t filter, zval
**filter_args, const int copy, php_int_t filter_flags TSRMLS_DC) /* {{{ */
{
zval *options = NULL;
zval **option;
char *charset = NULL;
if (filter_args && Z_TYPE_PP(filter_args) != IS_ARRAY) {
- long lval;
+ php_int_t lval;
PHP_FILTER_GET_LONG_OPT(filter_args, lval);
@@ -681,8 +681,8 @@ static void php_filter_call(zval **filtered, long filter,
zval **filter_args, co
static void php_filter_array_handler(zval *input, zval **op, zval
*return_value, zend_bool add_empty TSRMLS_DC) /* {{{ */
{
char *arg_key;
- uint arg_key_len;
- ulong index;
+ zend_str_size_uint arg_key_len;
+ php_uint_t index;
HashPosition pos;
zval **tmp, **arg_elm;
@@ -737,13 +737,13 @@ static void php_filter_array_handler(zval *input, zval
**op, zval *return_value,
*/
PHP_FUNCTION(filter_input)
{
- long fetch_from, filter = FILTER_DEFAULT;
+ php_int_t fetch_from, filter = FILTER_DEFAULT;
zval **filter_args = NULL, **tmp;
zval *input = NULL;
char *var;
- int var_len;
+ zend_str_size_int var_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|lZ",
&fetch_from, &var, &var_len, &filter, &filter_args) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iS|iZ",
&fetch_from, &var, &var_len, &filter, &filter_args) == FAILURE) {
return;
}
@@ -754,7 +754,7 @@ PHP_FUNCTION(filter_input)
input = php_filter_get_storage(fetch_from TSRMLS_CC);
if (!input || !HASH_OF(input) || zend_hash_find(HASH_OF(input), var,
var_len + 1, (void **)&tmp) != SUCCESS) {
- long filter_flags = 0;
+ php_int_t filter_flags = 0;
zval **option, **opt, **def;
if (filter_args) {
if (Z_TYPE_PP(filter_args) == IS_LONG) {
@@ -795,10 +795,10 @@ PHP_FUNCTION(filter_input)
*/
PHP_FUNCTION(filter_var)
{
- long filter = FILTER_DEFAULT;
+ php_int_t filter = FILTER_DEFAULT;
zval **filter_args = NULL, *data;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|lZ", &data,
&filter, &filter_args) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|iZ", &data,
&filter, &filter_args) == FAILURE) {
return;
}
@@ -817,11 +817,11 @@ PHP_FUNCTION(filter_var)
*/
PHP_FUNCTION(filter_input_array)
{
- long fetch_from;
+ php_int_t fetch_from;
zval *array_input = NULL, **op = NULL;
zend_bool add_empty = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|Zb",
&fetch_from, &op, &add_empty) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|Zb",
&fetch_from, &op, &add_empty) == FAILURE) {
return;
}
@@ -835,7 +835,7 @@ PHP_FUNCTION(filter_input_array)
array_input = php_filter_get_storage(fetch_from TSRMLS_CC);
if (!array_input || !HASH_OF(array_input)) {
- long filter_flags = 0;
+ php_int_t filter_flags = 0;
zval **option;
if (op) {
if (Z_TYPE_PP(op) == IS_LONG) {
@@ -905,11 +905,12 @@ PHP_FUNCTION(filter_list)
* Returns the filter ID belonging to a named filter */
PHP_FUNCTION(filter_id)
{
- int i, filter_len;
+ int i;
+ zend_str_size_int filter_len;
int size = sizeof(filter_list) / sizeof(filter_list_entry);
char *filter;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filter,
&filter_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &filter,
&filter_len) == FAILURE) {
return;
}
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index 39433d6..987e583 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -56,7 +56,7 @@
if (zend_hash_find(HASH_OF(option_array), option_name,
sizeof(option_name), (void **) &option_val) == SUCCESS) { \
if (Z_TYPE_PP(option_val) == IS_STRING) {
\
var_name = Z_STRVAL_PP(option_val);
\
- var_name##_len = Z_STRLEN_PP(option_val);
\
+ var_name##_len = Z_STRSIZE_PP(option_val);
\
var_name##_set = 1;
\
}
\
}
\
@@ -66,8 +66,8 @@
#define FORMAT_IPV4 4
#define FORMAT_IPV6 6
-static int php_filter_parse_int(const char *str, unsigned int str_len, long
*ret TSRMLS_DC) { /* {{{ */
- long ctx_value;
+static int php_filter_parse_int(const char *str, zend_str_size_uint str_len,
php_int_t *ret TSRMLS_DC) { /* {{{ */
+ php_int_t ctx_value;
int sign = 0, digit = 0;
const char *end = str + str_len;
@@ -101,9 +101,9 @@ static int php_filter_parse_int(const char *str, unsigned
int str_len, long *ret
while (str < end) {
if (*str >= '0' && *str <= '9') {
digit = (*(str++) - '0');
- if ( (!sign) && ctx_value <= (LONG_MAX-digit)/10 ) {
+ if ( (!sign) && ctx_value <= (PHP_INT_MAX-digit)/10 ) {
ctx_value = (ctx_value * 10) + digit;
- } else if ( sign && ctx_value >= (LONG_MIN+digit)/10) {
+ } else if ( sign && ctx_value >=
(PHP_INT_MIN+digit)/10) {
ctx_value = (ctx_value * 10) - digit;
} else {
return -1;
@@ -118,16 +118,16 @@ static int php_filter_parse_int(const char *str, unsigned
int str_len, long *ret
}
/* }}} */
-static int php_filter_parse_octal(const char *str, unsigned int str_len, long
*ret TSRMLS_DC) { /* {{{ */
- unsigned long ctx_value = 0;
+static int php_filter_parse_octal(const char *str, zend_str_size_uint str_len,
php_int_t *ret TSRMLS_DC) { /* {{{ */
+ php_uint_t ctx_value = 0;
const char *end = str + str_len;
while (str < end) {
if (*str >= '0' && *str <= '7') {
- unsigned long n = ((*(str++)) - '0');
+ php_uint_t n = ((*(str++)) - '0');
- if ((ctx_value > ((unsigned long)(~(long)0)) / 8) ||
- ((ctx_value = ctx_value * 8) > ((unsigned
long)(~(long)0)) - n)) {
+ if ((ctx_value > ((php_uint_t)(~(php_int_t)0)) / 8) ||
+ ((ctx_value = ctx_value * 8) >
((php_uint_t)(~(php_int_t)0)) - n)) {
return -1;
}
ctx_value += n;
@@ -136,15 +136,15 @@ static int php_filter_parse_octal(const char *str,
unsigned int str_len, long *r
}
}
- *ret = (long)ctx_value;
+ *ret = (php_int_t)ctx_value;
return 1;
}
/* }}} */
-static int php_filter_parse_hex(const char *str, unsigned int str_len, long
*ret TSRMLS_DC) { /* {{{ */
- unsigned long ctx_value = 0;
+static int php_filter_parse_hex(const char *str, zend_str_size_uint str_len,
php_int_t *ret TSRMLS_DC) { /* {{{ */
+ php_uint_t ctx_value = 0;
const char *end = str + str_len;
- unsigned long n;
+ php_uint_t n;
while (str < end) {
if (*str >= '0' && *str <= '9') {
@@ -156,14 +156,14 @@ static int php_filter_parse_hex(const char *str, unsigned
int str_len, long *ret
} else {
return -1;
}
- if ((ctx_value > ((unsigned long)(~(long)0)) / 16) ||
- ((ctx_value = ctx_value * 16) > ((unsigned
long)(~(long)0)) - n)) {
+ if ((ctx_value > ((php_uint_t)(~(php_int_t)0)) / 16) ||
+ ((ctx_value = ctx_value * 16) >
((php_uint_t)(~(php_int_t)0)) - n)) {
return -1;
}
ctx_value += n;
}
- *ret = (long)ctx_value;
+ *ret = (php_int_t)ctx_value;
return 1;
}
/* }}} */
@@ -171,11 +171,12 @@ static int php_filter_parse_hex(const char *str, unsigned
int str_len, long *ret
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
zval **option_val;
- long min_range, max_range, option_flags;
+ php_int_t min_range, max_range, option_flags;
int min_range_set, max_range_set;
int allow_octal = 0, allow_hex = 0;
- int len, error = 0;
- long ctx_value;
+ php_int_t len;
+ int error = 0;
+ php_int_t ctx_value;
char *p;
/* Parse options */
@@ -183,7 +184,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
FETCH_LONG_OPTION(max_range, "max_range");
option_flags = flags;
- len = Z_STRLEN_P(value);
+ len = Z_STRSIZE_P(value);
if (len == 0) {
RETURN_VALIDATION_FAILED
@@ -237,7 +238,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
char *str = Z_STRVAL_P(value);
- int len = Z_STRLEN_P(value);
+ zend_str_size_int len = Z_STRSIZE_P(value);
int ret;
PHP_FILTER_TRIM_DEFAULT_EX(str, len, 0);
@@ -315,12 +316,12 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{
*/
char dec_sep = '.';
char tsd_sep[3] = "',.";
- long lval;
+ php_int_t lval;
double dval;
int first, n;
- len = Z_STRLEN_P(value);
+ len = Z_STRSIZE_P(value);
str = Z_STRVAL_P(value);
PHP_FILTER_TRIM_DEFAULT(str, len);
@@ -412,8 +413,8 @@ void
php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
zval **option_val;
char *regexp;
- int regexp_len;
- long option_flags;
+ zend_str_size_int regexp_len;
+ php_int_t option_flags;
int regexp_set, option_flags_set;
pcre *re = NULL;
@@ -436,7 +437,7 @@ void
php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
if (!re) {
RETURN_VALIDATION_FAILED
}
- matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0,
0, ovector, 3);
+ matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRSIZE_P(value), 0,
0, ovector, 3);
/* 0 means that the vector is too small to hold all the captured
substring offsets */
if (matches < 0) {
@@ -448,16 +449,16 @@ void
php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
php_url *url;
- int old_len = Z_STRLEN_P(value);
+ zend_str_size_int old_len = Z_STRSIZE_P(value);
php_filter_url(value, flags, option_array, charset TSRMLS_CC);
- if (Z_TYPE_P(value) != IS_STRING || old_len != Z_STRLEN_P(value)) {
+ if (Z_TYPE_P(value) != IS_STRING || old_len != Z_STRSIZE_P(value)) {
RETURN_VALIDATION_FAILED
}
/* Use parse_url - if it returns false, we return NULL */
- url = php_url_parse_ex(Z_STRVAL_P(value), Z_STRLEN_P(value));
+ url = php_url_parse_ex(Z_STRVAL_P(value), Z_STRSIZE_P(value));
if (url == NULL) {
RETURN_VALIDATION_FAILED
@@ -536,7 +537,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
/* The maximum length of an e-mail address is 320 octets, per RFC 2821.
*/
- if (Z_STRLEN_P(value) > 320) {
+ if (Z_STRSIZE_P(value) > 320) {
RETURN_VALIDATION_FAILED
}
@@ -544,7 +545,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
if (!re) {
RETURN_VALIDATION_FAILED
}
- matches = pcre_exec(re, NULL, Z_STRVAL_P(value), Z_STRLEN_P(value), 0,
0, ovector, 3);
+ matches = pcre_exec(re, NULL, Z_STRVAL_P(value),
(int)Z_STRSIZE_P(value), 0, 0, ovector, 3);
/* 0 means that the vector is too small to hold all the captured
substring offsets */
if (matches < 0) {
@@ -554,7 +555,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
}
/* }}} */
-static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */
+static int _php_filter_validate_ipv4(char *str, zend_str_size_int str_len, int
*ip) /* {{{ */
{
const char *end = str + str_len;
int num, m;
@@ -589,7 +590,7 @@ static int _php_filter_validate_ipv4(char *str, int
str_len, int *ip) /* {{{ */
}
/* }}} */
-static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{
*/
+static int _php_filter_validate_ipv6(char *str, zend_str_size_int str_len
TSRMLS_DC) /* {{{ */
{
int compressed = 0;
int blocks = 0;
@@ -678,9 +679,9 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /*
{{{ */
int ip[4];
int mode;
- if (memchr(Z_STRVAL_P(value), ':', Z_STRLEN_P(value))) {
+ if (memchr(Z_STRVAL_P(value), ':', Z_STRSIZE_P(value))) {
mode = FORMAT_IPV6;
- } else if (memchr(Z_STRVAL_P(value), '.', Z_STRLEN_P(value))) {
+ } else if (memchr(Z_STRVAL_P(value), '.', Z_STRSIZE_P(value))) {
mode = FORMAT_IPV4;
} else {
RETURN_VALIDATION_FAILED
@@ -696,7 +697,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /*
{{{ */
switch (mode) {
case FORMAT_IPV4:
- if (!_php_filter_validate_ipv4(Z_STRVAL_P(value),
Z_STRLEN_P(value), ip)) {
+ if (!_php_filter_validate_ipv4(Z_STRVAL_P(value),
Z_STRSIZE_P(value), ip)) {
RETURN_VALIDATION_FAILED
}
@@ -730,18 +731,18 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
case FORMAT_IPV6:
{
int res = 0;
- res =
_php_filter_validate_ipv6(Z_STRVAL_P(value), Z_STRLEN_P(value) TSRMLS_CC);
+ res =
_php_filter_validate_ipv6(Z_STRVAL_P(value), Z_STRSIZE_P(value) TSRMLS_CC);
if (res < 1) {
RETURN_VALIDATION_FAILED
}
/* Check flags */
if (flags & FILTER_FLAG_NO_PRIV_RANGE) {
- if (Z_STRLEN_P(value) >=2 &&
(!strncasecmp("FC", Z_STRVAL_P(value), 2) || !strncasecmp("FD",
Z_STRVAL_P(value), 2))) {
+ if (Z_STRSIZE_P(value) >=2 &&
(!strncasecmp("FC", Z_STRVAL_P(value), 2) || !strncasecmp("FD",
Z_STRVAL_P(value), 2))) {
RETURN_VALIDATION_FAILED
}
}
if (flags & FILTER_FLAG_NO_RES_RANGE) {
- switch (Z_STRLEN_P(value)) {
+ switch (Z_STRSIZE_P(value)) {
case 1: case 0:
break;
case 2:
@@ -755,7 +756,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /*
{{{ */
}
break;
default:
- if (Z_STRLEN_P(value)
>= 5) {
+ if (Z_STRSIZE_P(value)
>= 5) {
if (
!strncasecmp("fe8", Z_STRVAL_P(value), 3) ||
!strncasecmp("fe9", Z_STRVAL_P(value), 3) ||
@@ -766,10 +767,10 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
}
}
if (
-
(Z_STRLEN_P(value) >= 9 && !strncasecmp("2001:0db8", Z_STRVAL_P(value), 9)) ||
-
(Z_STRLEN_P(value) >= 2 && !strncasecmp("5f", Z_STRVAL_P(value), 2)) ||
-
(Z_STRLEN_P(value) >= 4 && !strncasecmp("3ff3", Z_STRVAL_P(value), 4)) ||
-
(Z_STRLEN_P(value) >= 8 && !strncasecmp("2001:001", Z_STRVAL_P(value), 8))
+
(Z_STRSIZE_P(value) >= 9 && !strncasecmp("2001:0db8", Z_STRVAL_P(value), 9)) ||
+
(Z_STRSIZE_P(value) >= 2 && !strncasecmp("5f", Z_STRVAL_P(value), 2)) ||
+
(Z_STRSIZE_P(value) >= 4 && !strncasecmp("3ff3", Z_STRVAL_P(value), 4)) ||
+
(Z_STRSIZE_P(value) >= 8 && !strncasecmp("2001:001", Z_STRVAL_P(value), 8))
) {
RETURN_VALIDATION_FAILED
}
@@ -784,11 +785,12 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL)
/* {{{ */
void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
char *input = Z_STRVAL_P(value);
- int input_len = Z_STRLEN_P(value);
- int tokens, length, i, offset, exp_separator_set, exp_separator_len;
+ zend_str_size_int input_len = Z_STRSIZE_P(value);
+ int tokens, length, i, offset, exp_separator_set;
+ zend_str_size_int exp_separator_len;
char separator;
char *exp_separator;
- long ret = 0;
+ php_int_t ret = 0;
zval **option_val;
FETCH_STRING_OPTION(exp_separator, "separator");
diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h
index e31f0f0..6d83ab9 100644
--- a/ext/filter/php_filter.h
+++ b/ext/filter/php_filter.h
@@ -59,8 +59,8 @@ ZEND_BEGIN_MODULE_GLOBALS(filter)
zval *env_array;
zval *server_array;
zval *session_array;
- long default_filter;
- long default_filter_flags;
+ php_int_t default_filter;
+ php_int_t default_filter_flags;
ZEND_END_MODULE_GLOBALS(filter)
#ifdef ZTS
@@ -70,7 +70,7 @@ ZEND_END_MODULE_GLOBALS(filter)
#endif
-#define PHP_INPUT_FILTER_PARAM_DECL zval *value, long flags, zval
*option_array, char *charset TSRMLS_DC
+#define PHP_INPUT_FILTER_PARAM_DECL zval *value, php_int_t flags, zval
*option_array, char *charset TSRMLS_DC
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index 30da05a..284be60 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -30,18 +30,18 @@ typedef unsigned long filter_map[256];
static void php_filter_encode_html(zval *value, const unsigned char *chars)
{
smart_str str = {0};
- int len = Z_STRLEN_P(value);
+ zend_str_size_int len = Z_STRSIZE_P(value);
unsigned char *s = (unsigned char *)Z_STRVAL_P(value);
unsigned char *e = s + len;
- if (Z_STRLEN_P(value) == 0) {
+ if (Z_STRSIZE_P(value) == 0) {
return;
}
while (s < e) {
if (chars[*s]) {
smart_str_appendl(&str, "&#", 2);
- smart_str_append_unsigned(&str, (unsigned long)*s);
+ smart_str_append_unsigned(&str, (php_uint_t)*s);
smart_str_appendc(&str, ';');
} else {
/* XXX: this needs to be optimized to work with blocks
of 'safe' chars */
@@ -53,7 +53,7 @@ static void php_filter_encode_html(zval *value, const
unsigned char *chars)
smart_str_0(&str);
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = str.c;
- Z_STRLEN_P(value) = str.len;
+ Z_STRSIZE_P(value) = str.len;
}
static const unsigned char hexchars[] = "0123456789ABCDEF";
@@ -64,7 +64,7 @@ static const unsigned char hexchars[] = "0123456789ABCDEF";
#define DEFAULT_URL_ENCODE LOWALPHA HIALPHA DIGIT "-._"
-static void php_filter_encode_url(zval *value, const unsigned char* chars,
const int char_len, int high, int low, int encode_nul)
+static void php_filter_encode_url(zval *value, const unsigned char* chars,
const zend_str_size_int char_len, int high, int low, int encode_nul)
{
unsigned char *str, *p;
unsigned char tmp[256];
@@ -87,9 +87,9 @@ static void php_filter_encode_url(zval *value, const unsigned
char* chars, const
memset(tmp, 1, 32);
}
*/
- p = str = (unsigned char *) safe_emalloc(3, Z_STRLEN_P(value), 1);
+ p = str = (unsigned char *) safe_emalloc(3, Z_STRSIZE_P(value), 1);
s = (unsigned char *)Z_STRVAL_P(value);
- e = s + Z_STRLEN_P(value);
+ e = s + Z_STRSIZE_P(value);
while (s < e) {
if (tmp[*s]) {
@@ -104,10 +104,10 @@ static void php_filter_encode_url(zval *value, const
unsigned char* chars, const
*p = '\0';
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = (char *)str;
- Z_STRLEN_P(value) = p - str;
+ Z_STRSIZE_P(value) = p - str;
}
-static void php_filter_strip(zval *value, long flags)
+static void php_filter_strip(zval *value, php_int_t flags)
{
unsigned char *buf, *str;
int i, c;
@@ -118,9 +118,9 @@ static void php_filter_strip(zval *value, long flags)
}
str = (unsigned char *)Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
+ buf = safe_emalloc(1, Z_STRSIZE_P(value) + 1, 1);
c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
+ for (i = 0; i < Z_STRSIZE_P(value); i++) {
if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
} else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
} else if ((str[i] == '`') && (flags &
FILTER_FLAG_STRIP_BACKTICK)) {
@@ -133,7 +133,7 @@ static void php_filter_strip(zval *value, long flags)
buf[c] = '\0';
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = (char *)buf;
- Z_STRLEN_P(value) = c;
+ Z_STRSIZE_P(value) = c;
}
/* }}} */
@@ -145,7 +145,7 @@ static void filter_map_init(filter_map *map)
static void filter_map_update(filter_map *map, int flag, const unsigned char
*allowed_list)
{
- int l, i;
+ zend_str_size_int l, i;
l = strlen((const char*)allowed_list);
for (i = 0; i < l; ++i) {
@@ -159,9 +159,9 @@ static void filter_map_apply(zval *value, filter_map *map)
int i, c;
str = (unsigned char *)Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
+ buf = safe_emalloc(1, Z_STRSIZE_P(value) + 1, 1);
c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
+ for (i = 0; i < Z_STRSIZE_P(value); i++) {
if ((*map)[str[i]]) {
buf[c] = str[i];
++c;
@@ -171,7 +171,7 @@ static void filter_map_apply(zval *value, filter_map *map)
buf[c] = '\0';
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = (char *)buf;
- Z_STRLEN_P(value) = c;
+ Z_STRSIZE_P(value) = c;
}
/* }}} */
@@ -200,8 +200,8 @@ void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
php_filter_encode_html(value, enc);
/* strip tags, implicitly also removes \0 chars */
- new_len = php_strip_tags_ex(Z_STRVAL_P(value), Z_STRLEN_P(value), NULL,
NULL, 0, 1);
- Z_STRLEN_P(value) = new_len;
+ new_len = php_strip_tags_ex(Z_STRVAL_P(value), Z_STRSIZE_P(value),
NULL, NULL, 0, 1);
+ Z_STRSIZE_P(value) = new_len;
if (new_len == 0) {
zval_dtor(value);
@@ -258,10 +258,10 @@ void
php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL)
} else {
quotes = ENT_NOQUOTES;
}
- buf = php_escape_html_entities_ex(Z_STRVAL_P(value), Z_STRLEN_P(value),
&len, 1, quotes, SG(default_charset), 0 TSRMLS_CC);
+ buf = php_escape_html_entities_ex(Z_STRVAL_P(value),
Z_STRSIZE_P(value), &len, 1, quotes, SG(default_charset), 0 TSRMLS_CC);
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = len;
+ Z_STRSIZE_P(value) = len;
}
/* }}} */
@@ -269,7 +269,7 @@ void
php_filter_full_special_chars(PHP_INPUT_FILTER_PARAM_DECL)
void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
{
/* Only if no flags are set (optimization) */
- if (flags != 0 && Z_STRLEN_P(value) > 0) {
+ if (flags != 0 && Z_STRSIZE_P(value) > 0) {
unsigned char enc[256] = {0};
php_filter_strip(value, flags);
@@ -285,7 +285,7 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
}
php_filter_encode_html(value, enc);
- } else if (flags & FILTER_FLAG_EMPTY_STRING_NULL && Z_STRLEN_P(value)
== 0) {
+ } else if (flags & FILTER_FLAG_EMPTY_STRING_NULL && Z_STRSIZE_P(value)
== 0) {
zval_dtor(value);
ZVAL_NULL(value);
}
@@ -368,14 +368,14 @@ void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL)
void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL)
{
char *buf;
- int len;
+ zend_str_size_int len;
/* just call php_addslashes quotes */
- buf = php_addslashes(Z_STRVAL_P(value), Z_STRLEN_P(value), &len, 0
TSRMLS_CC);
+ buf = php_addslashes(Z_STRVAL_P(value), Z_STRSIZE_P(value), &len, 0
TSRMLS_CC);
str_efree(Z_STRVAL_P(value));
Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = len;
+ Z_STRSIZE_P(value) = len;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php