]> granicus.if.org Git - php/commitdiff
- Fix #31442 unserialize broken on 64-bit systems
authorMarcus Boerger <helly@php.net>
Wed, 9 Mar 2005 23:58:44 +0000 (23:58 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 9 Mar 2005 23:58:44 +0000 (23:58 +0000)
- Fix one warning

ext/standard/var_unserializer.c

index 86653737a3f37471cb0b7a55d075264480f69432..474a21f46b7c4fb6f5d5787d1030bf72ce14f6df 100644 (file)
@@ -1,5 +1,5 @@
-/* Generated by re2c 0.9.4 on Tue Mar  8 08:39:34 2005 */
-#line 1 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+/* Generated by re2c 0.9.4 on Thu Mar 10 00:54:25 2005 */
+#line 1 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 /*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
@@ -29,7 +29,7 @@
 
 typedef struct {
        zval *data[VAR_ENTRIES_MAX];
-       int used_slots;
+       long used_slots;
        void *next;
 } var_entries;
 
@@ -82,7 +82,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) {
@@ -96,7 +96,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;
        
@@ -117,7 +117,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) {
@@ -147,15 +147,15 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
 #define YYMARKER marker
 
 
-#line 155 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 155 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 
 
 
 
-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) {
@@ -180,7 +180,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);
 }
@@ -210,7 +210,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;
@@ -279,7 +279,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);
@@ -291,7 +291,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;
        }
 
@@ -304,10 +304,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;
@@ -316,7 +316,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;
@@ -448,7 +448,7 @@ yy3:        yyaccept = 0;
        if(yych == ':') goto yy87;
        goto yy4;
 yy4:
-#line 625 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 625 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 { return 0; }
 #line 103 "<stdout>"
 yy5:   yyaccept = 0;
@@ -489,7 +489,7 @@ yy13:       yyaccept = 0;
 yy14:  ++YYCURSOR;
        goto yy15;
 yy15:
-#line 619 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 619 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        /* this is the case where we have less data than planned */
        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
@@ -518,10 +518,10 @@ yy21:     yych = *++YYCURSOR;
 yy22:  ++YYCURSOR;
        goto yy23;
 yy23:
-#line 507 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 507 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        size_t len, len2, len3, maxlen;
-       int elements;
+       long elements;
        char *class_name;
        zend_class_entry *ce;
        zend_class_entry **pce;
@@ -659,7 +659,7 @@ yy28:       yych = *++YYCURSOR;
 yy29:  ++YYCURSOR;
        goto yy30;
 yy30:
-#line 499 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 499 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
 
        INIT_PZVAL(*rval);
@@ -691,10 +691,10 @@ yy35:     yych = *++YYCURSOR;
 yy36:  ++YYCURSOR;
        goto yy37;
 yy37:
-#line 477 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 477 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
-       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) {
@@ -737,7 +737,7 @@ yy42:       yych = *++YYCURSOR;
 yy43:  ++YYCURSOR;
        goto yy44;
 yy44:
-#line 449 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 449 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        size_t len, maxlen;
        char *str;
@@ -854,11 +854,11 @@ yy54:     if(yych <= ';'){
 yy55:  ++YYCURSOR;
        goto yy56;
 yy56:
-#line 442 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 442 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        *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;
 }
 #line 520 "<stdout>"
@@ -921,7 +921,7 @@ yy65:       yych = *++YYCURSOR;
 yy66:  ++YYCURSOR;
        goto yy67;
 yy67:
-#line 427 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 427 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        *p = YYCURSOR;
        INIT_PZVAL(*rval);
@@ -965,7 +965,7 @@ yy72:       if(yych <= '/') goto yy2;
 yy73:  ++YYCURSOR;
        goto yy74;
 yy74:
-#line 420 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 420 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        *p = YYCURSOR;
        INIT_PZVAL(*rval);
@@ -983,7 +983,7 @@ yy76:       yych = *++YYCURSOR;
 yy77:  ++YYCURSOR;
        goto yy78;
 yy78:
-#line 413 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 413 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        *p = YYCURSOR;
        INIT_PZVAL(*rval);
@@ -994,7 +994,7 @@ yy78:
 yy79:  ++YYCURSOR;
        goto yy80;
 yy80:
-#line 406 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 406 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
        *p = YYCURSOR;
        INIT_PZVAL(*rval);
@@ -1027,9 +1027,9 @@ yy84:     if(yych <= '/') goto yy2;
 yy85:  ++YYCURSOR;
        goto yy86;
 yy86:
-#line 383 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 383 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
-       int id;
+       long id;
 
        *p = YYCURSOR;
        if (!var_hash) return 0;
@@ -1076,9 +1076,9 @@ yy90:     if(yych <= '/') goto yy2;
 yy91:  ++YYCURSOR;
        goto yy92;
 yy92:
-#line 362 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 362 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 {
-       int id;
+       long id;
 
        *p = YYCURSOR;
        if (!var_hash) return 0;
@@ -1099,7 +1099,7 @@ yy92:
 }
 #line 761 "<stdout>"
 }
-#line 627 "/usr/src/php/php5/ext/standard/var_unserializer.re"
+#line 627 "/usr/src/php-cvs/ext/standard/var_unserializer.re"
 
 
        return 0;