From: Marcus Boerger Date: Thu, 10 Mar 2005 00:10:21 +0000 (+0000) Subject: - Fix #31442 unserialize broken on 64-bit systems X-Git-Tag: php-5.0.1b1~873 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22fcd1aac7ce9e5e310c3123f40c349d3df528d0;p=php - Fix #31442 unserialize broken on 64-bit systems - Fix one warning --- diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 8b2c79cdcd..23cb4317db 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -27,7 +27,7 @@ typedef struct { zval *data[VAR_ENTRIES_MAX]; - int used_slots; + long used_slots; void *next; } var_entries; @@ -80,7 +80,7 @@ static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval) PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval) { - int i; + long i; var_entries *var_hash = var_hashx->first; while (var_hash) { @@ -94,7 +94,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **n } } -static int var_access(php_unserialize_data_t *var_hashx, int id, zval ***store) +static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store) { var_entries *var_hash = var_hashx->first; @@ -115,7 +115,7 @@ static int var_access(php_unserialize_data_t *var_hashx, int id, zval ***store) PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) { void *next; - int i; + long i; var_entries *var_hash = var_hashx->first; while (var_hash) { @@ -156,10 +156,10 @@ object = [OC]; -static inline int parse_iv2(const unsigned char *p, const unsigned char **q) +static inline long parse_iv2(const unsigned char *p, const unsigned char **q) { char cursor; - int result = 0; + long result = 0; int neg = 0; switch (*p) { @@ -184,7 +184,7 @@ static inline int parse_iv2(const unsigned char *p, const unsigned char **q) return result; } -static inline int parse_iv(const unsigned char *p) +static inline long parse_iv(const unsigned char *p) { return parse_iv2(p, NULL); } @@ -214,7 +214,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, int elements) +static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements) { while (elements-- > 0) { zval *key, *data, **old_data; @@ -283,7 +283,7 @@ static inline int finish_nested_data(UNSERIALIZE_PARAMETER) static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { - int datalen; + long datalen; if(ce->unserialize == NULL) { zend_error(E_WARNING, "Class %s has no unserializer", ce->name); @@ -295,7 +295,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) (*p) += 2; if(datalen < 0 || (*p) + datalen >= max) { - zend_error(E_WARNING, "Insufficient data for unserializing - %d required, %d present", datalen, max - (*p)); + zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %d present", datalen, max - (*p)); return 0; } @@ -308,10 +308,10 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) return finish_nested_data(UNSERIALIZE_PASSTHRU); } -static inline int object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) +static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { - int elements; - + long elements; + elements = parse_iv2((*p) + 2, p); (*p) += 2; @@ -320,7 +320,7 @@ static inline int object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce) return elements; } -static inline int object_common2(UNSERIALIZE_PARAMETER, int elements) +static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) { zval *retval_ptr = NULL; zval fname; @@ -360,7 +360,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) /*!re2c "R:" iv ";" { - int id; + long id; *p = YYCURSOR; if (!var_hash) return 0; @@ -381,7 +381,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } "r:" iv ";" { - int id; + long id; *p = YYCURSOR; if (!var_hash) return 0; @@ -442,7 +442,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) "d:" (iv | nv | nvexp) ";" { *p = YYCURSOR; INIT_PZVAL(*rval); - ZVAL_DOUBLE(*rval, zend_strtod(start + 2, NULL)); + ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } @@ -475,8 +475,8 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) } "a:" uiv ":" "{" { - int elements = parse_iv(start + 2); - + long elements = parse_iv(start + 2); + /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; if (elements < 0) { @@ -506,7 +506,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) object ":" uiv ":" ["] { size_t len, len2, len3, maxlen; - int elements; + long elements; char *class_name; zend_class_entry *ce; zend_class_entry **pce;