Skip to content

Commit f4c4fe4

Browse files
committed
Get core test suite to really pass, fully. Woot
1 parent 3db6b51 commit f4c4fe4

File tree

7 files changed

+26
-21
lines changed

7 files changed

+26
-21
lines changed

Zend/zend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ struct _zend_class_entry {
512512
union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, zend_str_size_int method_len TSRMLS_DC);
513513

514514
/* serializer callbacks */
515-
zend_str_size_int (*serialize)(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
516-
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);
515+
int (*serialize)(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
516+
int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
517517

518518
zend_class_entry **interfaces;
519519
zend_uint num_interfaces;

Zend/zend_interfaces.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ZEND_API zend_class_entry *zend_ce_serializable;
3131

3232
/* {{{ zend_call_method
3333
Only returns the returned zval if retval_ptr != NULL */
34-
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)
34+
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)
3535
{
3636
int result;
3737
zend_fcall_info fci;
@@ -397,7 +397,7 @@ static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_en
397397
/* }}}*/
398398

399399
/* {{{ zend_user_serialize */
400-
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
400+
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
401401
{
402402
zend_class_entry * ce = Z_OBJCE_P(object);
403403
zval *retval;
@@ -434,7 +434,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint
434434
/* }}} */
435435

436436
/* {{{ zend_user_unserialize */
437-
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)
437+
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)
438438
{
439439
zval * zdata;
440440

@@ -455,15 +455,15 @@ ZEND_API int zend_user_unserialize(zval **object, zend_class_entry *ce, const un
455455
}
456456
/* }}} */
457457

458-
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
458+
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
459459
{
460460
zend_class_entry *ce = Z_OBJCE_P(object);
461461
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Serialization of '%s' is not allowed", ce->name);
462462
return FAILURE;
463463
}
464464
/* }}} */
465465

466-
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) /* {{{ */
466+
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) /* {{{ */
467467
{
468468
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Unserialization of '%s' is not allowed", ce->name);
469469
return FAILURE;

Zend/zend_interfaces.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct _zend_user_iterator {
3838
zval *value;
3939
} zend_user_iterator;
4040

41-
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);
41+
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);
4242

4343
#define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \
4444
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
6161

6262
ZEND_API void zend_register_interfaces(TSRMLS_D);
6363

64-
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
65-
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);
64+
ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
65+
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);
6666

67-
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
68-
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);
67+
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
68+
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);
6969

7070
END_EXTERN_C()
7171

ext/standard/php_smart_str.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@
8888
smart_str_append_ex((dest), (src), 0)
8989
#define smart_str_append_long(dest, val) \
9090
smart_str_append_long_ex((dest), (val), 0)
91+
#define smart_str_append_str_size(dest, val) \
92+
smart_str_append_str_size_ex((dest), (val), 0)
9193
#define smart_str_append_off_t(dest, val) \
9294
smart_str_append_off_t_ex((dest), (val), 0)
9395
#define smart_str_append_unsigned(dest, val) \
9496
smart_str_append_unsigned_ex((dest), (val), 0)
9597

9698
#define smart_str_appendc_ex(dest, ch, what) do { \
97-
register size_t __nl; \
99+
register zend_str_size __nl; \
98100
smart_str_alloc4((dest), 1, (what), __nl); \
99101
(dest)->len = __nl; \
100102
((unsigned char *) (dest)->c)[(dest)->len - 1] = (ch); \
@@ -110,7 +112,7 @@
110112
} while (0)
111113

112114
#define smart_str_appendl_ex(dest, src, nlen, what) do { \
113-
register size_t __nl; \
115+
register zend_str_size __nl; \
114116
smart_str *__dest = (smart_str *) (dest); \
115117
\
116118
smart_str_alloc4(__dest, (nlen), (what), __nl); \
@@ -175,6 +177,9 @@ static inline char *smart_str_print_unsigned(char *buf, long num) {
175177
#define smart_str_append_long_ex(dest, num, type) \
176178
smart_str_append_generic_ex((dest), (num), (type), unsigned long, _long)
177179

180+
#define smart_str_append_str_size_ex(dest, num, type) \
181+
smart_str_append_generic_ex((dest), (num), (type), zend_str_size, _long)
182+
178183
#define smart_str_append_off_t_ex(dest, num, type) \
179184
smart_str_append_generic_ex((dest), (num), (type), off_t, _long)
180185

ext/standard/php_smart_str_public.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
typedef struct {
2727
char *c;
28-
size_t len;
29-
size_t a;
28+
zend_str_size len;
29+
zend_str_size a;
3030
} smart_str;
3131

3232
#endif

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ PHP_FUNCTION(substr)
22372237
l = str_len;
22382238
}
22392239

2240-
if (f > str_len) {
2240+
if (f > 0 && f > str_len) {
22412241
RETURN_FALSE;
22422242
} else if (f < 0 && -f > str_len) {
22432243
f = 0;

ext/standard/var.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static inline void php_var_serialize_long(smart_str *buf, long val) /* {{{ */
595595
static inline void php_var_serialize_string(smart_str *buf, char *str, zend_str_size_int len) /* {{{ */
596596
{
597597
smart_str_appendl(buf, "s:", 2);
598-
smart_str_append_long(buf, len);
598+
smart_str_append_str_size(buf, len);
599599
smart_str_appendl(buf, ":\"", 2);
600600
smart_str_appendl(buf, str, len);
601601
smart_str_appendl(buf, "\";", 2);
@@ -608,7 +608,7 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc
608608

609609
PHP_SET_CLASS_ATTRIBUTES(struc);
610610
smart_str_appendl(buf, "O:", 2);
611-
smart_str_append_long(buf, (long)name_len);
611+
smart_str_append_str_size(buf, name_len);
612612
smart_str_appendl(buf, ":\"", 2);
613613
smart_str_appendl(buf, class_name, name_len);
614614
smart_str_appendl(buf, "\":", 2);
@@ -780,12 +780,12 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
780780

781781
if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) {
782782
smart_str_appendl(buf, "C:", 2);
783-
smart_str_append_long(buf, (int)Z_OBJCE_P(struc)->name_length);
783+
smart_str_append_str_size(buf, Z_OBJCE_P(struc)->name_length);
784784
smart_str_appendl(buf, ":\"", 2);
785785
smart_str_appendl(buf, Z_OBJCE_P(struc)->name, Z_OBJCE_P(struc)->name_length);
786786
smart_str_appendl(buf, "\":", 2);
787787

788-
smart_str_append_long(buf, (int)serialized_length);
788+
smart_str_append_str_size(buf, serialized_length);
789789
smart_str_appendl(buf, ":{", 2);
790790
smart_str_appendl(buf, serialized_data, serialized_length);
791791
smart_str_appendc(buf, '}');

0 commit comments

Comments
 (0)