diff options
Diffstat (limited to 'ext/standard/var_unserializer.re')
| -rw-r--r-- | ext/standard/var_unserializer.re | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 57570ab7f9..054580ac41 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -28,13 +28,13 @@ typedef struct { zval *data[VAR_ENTRIES_MAX]; - php_int_t used_slots; + zend_long used_slots; void *next; } var_entries; typedef struct { zval data[VAR_ENTRIES_MAX]; - php_int_t used_slots; + zend_long used_slots; void *next; } var_dtor_entries; @@ -117,7 +117,7 @@ PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rva PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval) { - php_int_t i; + zend_long i; var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval)); @@ -134,7 +134,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nz } } -static zval *var_access(php_unserialize_data_t *var_hashx, php_int_t id) +static zval *var_access(php_unserialize_data_t *var_hashx, zend_long id) { var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG @@ -156,7 +156,7 @@ static zval *var_access(php_unserialize_data_t *var_hashx, php_int_t id) PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) { void *next; - php_int_t i; + zend_long i; var_entries *var_hash = (*var_hashx)->first; var_dtor_entries *var_dtor_hash = (*var_hashx)->first_dtor; #if VAR_ENTRIES_DBG @@ -184,17 +184,17 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t maxlen) { size_t i, j; - zend_string *str = STR_ALLOC(len, 0); + zend_string *str = zend_string_alloc(len, 0); unsigned char *end = *(unsigned char **)p+maxlen; if (end < *p) { - STR_FREE(str); + zend_string_free(str); return NULL; } for (i = 0; i < len; i++) { if (*p >= end) { - STR_FREE(str); + zend_string_free(str); return NULL; } if (**p != '\\') { @@ -211,7 +211,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t } else if (**p >= 'A' && **p <= 'F') { ch = (ch << 4) + (**p -'A'+10); } else { - STR_FREE(str); + zend_string_free(str); return NULL; } } @@ -242,10 +242,10 @@ object = [OC]; -static inline php_int_t parse_iv2(const unsigned char *p, const unsigned char **q) +static inline zend_long parse_iv2(const unsigned char *p, const unsigned char **q) { char cursor; - php_int_t result = 0; + zend_long result = 0; int neg = 0; switch (*p) { @@ -270,7 +270,7 @@ static inline php_int_t parse_iv2(const unsigned char *p, const unsigned char ** return result; } -static inline php_int_t parse_iv(const unsigned char *p) +static inline zend_long parse_iv(const unsigned char *p) { return parse_iv2(p, NULL); } @@ -300,7 +300,7 @@ static inline size_t parse_uiv(const unsigned char *p) #define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC #define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC -static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, php_int_t elements, int objprops) +static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops) { while (elements-- > 0) { zval key, *data, d, *old_data; @@ -311,7 +311,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, php_ return 0; } - if (Z_TYPE(key) != IS_INT && Z_TYPE(key) != IS_STRING) { + if (Z_TYPE(key) != IS_LONG && Z_TYPE(key) != IS_STRING) { zval_dtor(&key); return 0; } @@ -321,12 +321,12 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, php_ if (!objprops) { switch (Z_TYPE(key)) { - case IS_INT: - if ((old_data = zend_hash_index_find(ht, Z_IVAL(key))) != NULL) { + case IS_LONG: + if ((old_data = zend_hash_index_find(ht, Z_LVAL(key))) != NULL) { //??? update hash var_push_dtor(var_hash, old_data); } - data = zend_hash_index_update(ht, Z_IVAL(key), &d); + data = zend_hash_index_update(ht, Z_LVAL(key), &d); break; case IS_STRING: if ((old_data = zend_symtable_find(ht, Z_STR(key))) != NULL) { @@ -384,14 +384,14 @@ static inline int finish_nested_data(UNSERIALIZE_PARAMETER) static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { - php_int_t datalen; + zend_long datalen; datalen = parse_iv2((*p) + 2, p); (*p) += 2; if (datalen < 0 || (*p) + datalen >= max) { - zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %pd present", datalen, (php_int_t)(max - (*p))); + zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %pd present", datalen, (zend_long)(max - (*p))); return 0; } @@ -407,9 +407,9 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) return finish_nested_data(UNSERIALIZE_PASSTHRU); } -static inline php_int_t object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) +static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { - php_int_t elements; + zend_long elements; elements = parse_iv2((*p) + 2, p); @@ -430,7 +430,7 @@ static inline php_int_t object_common1(UNSERIALIZE_PARAMETER, zend_class_entry * #ifdef PHP_WIN32 # pragma optimize("", off) #endif -static inline int object_common2(UNSERIALIZE_PARAMETER, php_int_t elements) +static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements) { zval retval; zval fname; @@ -487,7 +487,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) /*!re2c "R:" iv ";" { - php_int_t id; + zend_long id; *p = YYCURSOR; if (!var_hash) return 0; @@ -509,7 +509,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } "r:" iv ";" { - php_int_t id; + zend_long id; *p = YYCURSOR; if (!var_hash) return 0; @@ -551,10 +551,10 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) digits--; } - /* Use double for large php_int_t values that were serialized on a 64-bit system */ - if (digits >= MAX_LENGTH_OF_ZEND_INT - 1) { - if (digits == MAX_LENGTH_OF_ZEND_INT - 1) { - int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_ZEND_INT, int_min_digits, MAX_LENGTH_OF_ZEND_INT - 1); + /* Use double for large zend_long values that were serialized on a 64-bit system */ + if (digits >= MAX_LENGTH_OF_LONG - 1) { + if (digits == MAX_LENGTH_OF_LONG - 1) { + int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1); if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) { goto use_double; @@ -565,7 +565,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } #endif *p = YYCURSOR; - ZVAL_INT(rval, parse_iv(start + 2)); + ZVAL_LONG(rval, parse_iv(start + 2)); return 1; } @@ -637,7 +637,7 @@ use_double: } if (*(YYCURSOR) != '"') { - STR_FREE(str); + zend_string_free(str); *p = YYCURSOR; return 0; } @@ -650,7 +650,7 @@ use_double: } "a:" uiv ":" "{" { - php_int_t elements = parse_iv(start + 2); + zend_long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; @@ -680,7 +680,7 @@ use_double: object ":" uiv ":" ["] { size_t len, len2, len3, maxlen; - php_int_t elements; + zend_long elements; char *str; zend_string *class_name; zend_class_entry *ce; @@ -724,7 +724,7 @@ object ":" uiv ":" ["] { return 0; } - class_name = STR_INIT(str, len, 0); + class_name = zend_string_init(str, len, 0); do { /* Try to find class directly */ @@ -733,7 +733,7 @@ object ":" uiv ":" ["] { if (ce) { BG(serialize_lock)--; if (EG(exception)) { - STR_RELEASE(class_name); + zend_string_release(class_name); return 0; } break; @@ -741,7 +741,7 @@ object ":" uiv ":" ["] { BG(serialize_lock)--; if (EG(exception)) { - STR_RELEASE(class_name); + zend_string_release(class_name); return 0; } @@ -755,12 +755,12 @@ object ":" uiv ":" ["] { /* Call unserialize callback */ ZVAL_STRING(&user_func, PG(unserialize_callback_func)); - ZVAL_STR(&args[0], STR_COPY(class_name)); + ZVAL_STR(&args[0], zend_string_copy(class_name)); BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { - STR_RELEASE(class_name); + zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; @@ -775,7 +775,7 @@ object ":" uiv ":" ["] { BG(serialize_lock)--; zval_ptr_dtor(&retval); if (EG(exception)) { - STR_RELEASE(class_name); + zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; @@ -803,7 +803,7 @@ object ":" uiv ":" ["] { if (ret && incomplete_class) { php_store_class_name(rval, class_name->val, len2); } - STR_RELEASE(class_name); + zend_string_release(class_name); return ret; } @@ -812,7 +812,7 @@ object ":" uiv ":" ["] { if (incomplete_class) { php_store_class_name(rval, class_name->val, len2); } - STR_RELEASE(class_name); + zend_string_release(class_name); return object_common2(UNSERIALIZE_PASSTHRU, elements); } |
