diff --git a/Zend/zend.h b/Zend/zend.h index d40500caf7..e0a71e0f56 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -512,8 +512,8 @@ struct _zend_class_entry { union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, zend_str_size_int method_len TSRMLS_DC); /* serializer callbacks */ - zend_str_size_int (*serialize)(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC); - zend_str_size_int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC); + int (*serialize)(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC); + int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC); zend_class_entry **interfaces; zend_uint num_interfaces; diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 31cd261bc7..129c6851ea 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -31,7 +31,7 @@ ZEND_API zend_class_entry *zend_ce_serializable; /* {{{ zend_call_method Only returns the returned zval if retval_ptr != NULL */ -ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) +ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, zend_str_size_int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) { int result; zend_fcall_info fci; @@ -397,7 +397,7 @@ static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_en /* }}}*/ /* {{{ zend_user_serialize */ -ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) +ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC) { zend_class_entry * ce = Z_OBJCE_P(object); zval *retval; @@ -434,7 +434,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint /* }}} */ /* {{{ zend_user_unserialize */ -ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) +ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC) { zval * zdata; @@ -455,7 +455,7 @@ ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const un } /* }}} */ -ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */ +ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Serialization of '%s' is not allowed", ce->name); @@ -463,7 +463,7 @@ ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zen } /* }}} */ -ZEND_API int zend_class_unserialize_deny(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */ +ZEND_API int zend_class_unserialize_deny(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */ { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Unserialization of '%s' is not allowed", ce->name); return FAILURE; diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index ba4bc6ccb6..ec6dd515ab 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -38,7 +38,7 @@ typedef struct _zend_user_iterator { zval *value; } zend_user_iterator; -ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); +ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, zend_str_size_int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); #define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \ zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL TSRMLS_CC) @@ -61,11 +61,11 @@ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *c ZEND_API void zend_register_interfaces(TSRMLS_D); -ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC); -ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC); +ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC); +ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC); -ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC); -ZEND_API int zend_class_unserialize_deny(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC); +ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC); +ZEND_API int zend_class_unserialize_deny(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC); END_EXTERN_C() diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h index 2fef1d0bd0..7e8c4915fe 100644 --- a/ext/standard/php_smart_str.h +++ b/ext/standard/php_smart_str.h @@ -88,13 +88,15 @@ smart_str_append_ex((dest), (src), 0) #define smart_str_append_long(dest, val) \ smart_str_append_long_ex((dest), (val), 0) +#define smart_str_append_str_size(dest, val) \ + smart_str_append_str_size_ex((dest), (val), 0) #define smart_str_append_off_t(dest, val) \ smart_str_append_off_t_ex((dest), (val), 0) #define smart_str_append_unsigned(dest, val) \ smart_str_append_unsigned_ex((dest), (val), 0) #define smart_str_appendc_ex(dest, ch, what) do { \ - register size_t __nl; \ + register zend_str_size __nl; \ smart_str_alloc4((dest), 1, (what), __nl); \ (dest)->len = __nl; \ ((unsigned char *) (dest)->c)[(dest)->len - 1] = (ch); \ @@ -110,7 +112,7 @@ } while (0) #define smart_str_appendl_ex(dest, src, nlen, what) do { \ - register size_t __nl; \ + register zend_str_size __nl; \ smart_str *__dest = (smart_str *) (dest); \ \ smart_str_alloc4(__dest, (nlen), (what), __nl); \ @@ -175,6 +177,9 @@ static inline char *smart_str_print_unsigned(char *buf, long num) { #define smart_str_append_long_ex(dest, num, type) \ smart_str_append_generic_ex((dest), (num), (type), unsigned long, _long) +#define smart_str_append_str_size_ex(dest, num, type) \ + smart_str_append_generic_ex((dest), (num), (type), zend_str_size, _long) + #define smart_str_append_off_t_ex(dest, num, type) \ smart_str_append_generic_ex((dest), (num), (type), off_t, _long) diff --git a/ext/standard/php_smart_str_public.h b/ext/standard/php_smart_str_public.h index ed36a7a6fe..fdcb8b924e 100644 --- a/ext/standard/php_smart_str_public.h +++ b/ext/standard/php_smart_str_public.h @@ -25,8 +25,8 @@ typedef struct { char *c; - size_t len; - size_t a; + zend_str_size len; + zend_str_size a; } smart_str; #endif diff --git a/ext/standard/string.c b/ext/standard/string.c index a8c65fb01b..71f43f2fe0 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2237,7 +2237,7 @@ PHP_FUNCTION(substr) l = str_len; } - if (f > str_len) { + if (f > 0 && f > str_len) { RETURN_FALSE; } else if (f < 0 && -f > str_len) { f = 0; diff --git a/ext/standard/var.c b/ext/standard/var.c index abeb35dfd9..9e6be7d6a9 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -595,7 +595,7 @@ static inline void php_var_serialize_long(smart_str *buf, long val) /* {{{ */ static inline void php_var_serialize_string(smart_str *buf, char *str, zend_str_size_int len) /* {{{ */ { smart_str_appendl(buf, "s:", 2); - smart_str_append_long(buf, len); + smart_str_append_str_size(buf, len); smart_str_appendl(buf, ":\"", 2); smart_str_appendl(buf, str, len); smart_str_appendl(buf, "\";", 2); @@ -608,7 +608,7 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc PHP_SET_CLASS_ATTRIBUTES(struc); smart_str_appendl(buf, "O:", 2); - smart_str_append_long(buf, (long)name_len); + smart_str_append_str_size(buf, name_len); smart_str_appendl(buf, ":\"", 2); smart_str_appendl(buf, class_name, name_len); smart_str_appendl(buf, "\":", 2); @@ -780,12 +780,12 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { smart_str_appendl(buf, "C:", 2); - smart_str_append_long(buf, (int)Z_OBJCE_P(struc)->name_length); + smart_str_append_str_size(buf, Z_OBJCE_P(struc)->name_length); smart_str_appendl(buf, ":\"", 2); smart_str_appendl(buf, Z_OBJCE_P(struc)->name, Z_OBJCE_P(struc)->name_length); smart_str_appendl(buf, "\":", 2); - smart_str_append_long(buf, (int)serialized_length); + smart_str_append_str_size(buf, serialized_length); smart_str_appendl(buf, ":{", 2); smart_str_appendl(buf, serialized_data, serialized_length); smart_str_appendc(buf, '}');