Permalink
Browse files

Fixed bug #34879 (str_replace, array_map corrupt negative array index…

…es on 64-bit platforms)
  • Loading branch information...
Dmitry Stogov
Dmitry Stogov committed Oct 28, 2005
1 parent e9de9f3 commit b05b949a47952e09cc40087e9bddc0e39af34ebd
Showing with 37 additions and 24 deletions.
  1. +2 −0 NEWS
  2. +11 −0 Zend/tests/bug34879.phpt
  3. +12 −12 Zend/zend_API.c
  4. +12 −12 Zend/zend_API.h
View
2 NEWS
@@ -19,6 +19,8 @@ PHP NEWS
- Fixed bug #34893 (PHP5.1 overloading, Cannot access private property).
(Dmitry)
- Fixed bug #34899 (Fixed sqlite extension compile failure). (Ilia)
+- Fixed bug #34879 (str_replace, array_map corrupt negative array indexes on
+ 64-bit platforms). (Dmitry)
- Fixed bug #34821 (zlib encoders fail on widely varying binary data on windows)
(Mike, Ilia)
- Fixed bug #34782 (token_get_all() gives wrong result). (Dmitry)
View
@@ -0,0 +1,11 @@
+--TEST--
+Bug #34879 (str_replace, array_map corrupt negative array indexes on 64-bit platforms)
+--FILE--
+<?php
+print_r(str_replace('a', 'b', array(-1 =>-1)));
+?>
+--EXPECT--
+Array
+(
+ [-1] => -1
+)
View
@@ -935,7 +935,7 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value)
}
-ZEND_API int add_index_long(zval *arg, uint index, long n)
+ZEND_API int add_index_long(zval *arg, ulong index, long n)
{
zval *tmp;
@@ -946,7 +946,7 @@ ZEND_API int add_index_long(zval *arg, uint index, long n)
}
-ZEND_API int add_index_null(zval *arg, uint index)
+ZEND_API int add_index_null(zval *arg, ulong index)
{
zval *tmp;
@@ -956,7 +956,7 @@ ZEND_API int add_index_null(zval *arg, uint index)
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &tmp, sizeof(zval *), NULL);
}
-ZEND_API int add_index_bool(zval *arg, uint index, int b)
+ZEND_API int add_index_bool(zval *arg, ulong index, int b)
{
zval *tmp;
@@ -967,7 +967,7 @@ ZEND_API int add_index_bool(zval *arg, uint index, int b)
}
-ZEND_API int add_index_resource(zval *arg, uint index, int r)
+ZEND_API int add_index_resource(zval *arg, ulong index, int r)
{
zval *tmp;
@@ -978,7 +978,7 @@ ZEND_API int add_index_resource(zval *arg, uint index, int r)
}
-ZEND_API int add_index_double(zval *arg, uint index, double d)
+ZEND_API int add_index_double(zval *arg, ulong index, double d)
{
zval *tmp;
@@ -989,7 +989,7 @@ ZEND_API int add_index_double(zval *arg, uint index, double d)
}
-ZEND_API int add_index_string(zval *arg, uint index, char *str, int duplicate)
+ZEND_API int add_index_string(zval *arg, ulong index, char *str, int duplicate)
{
zval *tmp;
@@ -1000,7 +1000,7 @@ ZEND_API int add_index_string(zval *arg, uint index, char *str, int duplicate)
}
-ZEND_API int add_index_stringl(zval *arg, uint index, char *str, uint length, int duplicate)
+ZEND_API int add_index_stringl(zval *arg, ulong index, char *str, uint length, int duplicate)
{
zval *tmp;
@@ -1011,7 +1011,7 @@ ZEND_API int add_index_stringl(zval *arg, uint index, char *str, uint length, in
}
-ZEND_API int add_index_zval(zval *arg, uint index, zval *value)
+ZEND_API int add_index_zval(zval *arg, ulong index, zval *value)
{
return zend_hash_index_update(Z_ARRVAL_P(arg), index, (void *) &value, sizeof(zval *), NULL);
}
@@ -1122,7 +1122,7 @@ ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *
}
-ZEND_API int add_get_index_long(zval *arg, uint index, long l, void **dest)
+ZEND_API int add_get_index_long(zval *arg, ulong index, long l, void **dest)
{
zval *tmp;
@@ -1133,7 +1133,7 @@ ZEND_API int add_get_index_long(zval *arg, uint index, long l, void **dest)
}
-ZEND_API int add_get_index_double(zval *arg, uint index, double d, void **dest)
+ZEND_API int add_get_index_double(zval *arg, ulong index, double d, void **dest)
{
zval *tmp;
@@ -1144,7 +1144,7 @@ ZEND_API int add_get_index_double(zval *arg, uint index, double d, void **dest)
}
-ZEND_API int add_get_index_string(zval *arg, uint index, char *str, void **dest, int duplicate)
+ZEND_API int add_get_index_string(zval *arg, ulong index, char *str, void **dest, int duplicate)
{
zval *tmp;
@@ -1155,7 +1155,7 @@ ZEND_API int add_get_index_string(zval *arg, uint index, char *str, void **dest,
}
-ZEND_API int add_get_index_stringl(zval *arg, uint index, char *str, uint length, void **dest, int duplicate)
+ZEND_API int add_get_index_stringl(zval *arg, ulong index, char *str, uint length, void **dest, int duplicate)
{
zval *tmp;
View
@@ -294,14 +294,14 @@ ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
#define add_next_index_unset(__arg) add_next_index_null(__arg)
#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
-ZEND_API int add_index_long(zval *arg, uint idx, long n);
-ZEND_API int add_index_null(zval *arg, uint idx);
-ZEND_API int add_index_bool(zval *arg, uint idx, int b);
-ZEND_API int add_index_resource(zval *arg, uint idx, int r);
-ZEND_API int add_index_double(zval *arg, uint idx, double d);
-ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
-ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
-ZEND_API int add_index_zval(zval *arg, uint index, zval *value);
+ZEND_API int add_index_long(zval *arg, ulong idx, long n);
+ZEND_API int add_index_null(zval *arg, ulong idx);
+ZEND_API int add_index_bool(zval *arg, ulong idx, int b);
+ZEND_API int add_index_resource(zval *arg, ulong idx, int r);
+ZEND_API int add_index_double(zval *arg, ulong idx, double d);
+ZEND_API int add_index_string(zval *arg, ulong idx, char *str, int duplicate);
+ZEND_API int add_index_stringl(zval *arg, ulong idx, char *str, uint length, int duplicate);
+ZEND_API int add_index_zval(zval *arg, ulong index, zval *value);
ZEND_API int add_next_index_long(zval *arg, long n);
ZEND_API int add_next_index_null(zval *arg);
@@ -318,10 +318,10 @@ ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *
#define add_get_assoc_string(__arg, __key, __str, __dest, __duplicate) add_get_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __dest, __duplicate)
#define add_get_assoc_stringl(__arg, __key, __str, __length, __dest, __duplicate) add_get_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __dest, __duplicate)
-ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
-ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
-ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
-ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
+ZEND_API int add_get_index_long(zval *arg, ulong idx, long l, void **dest);
+ZEND_API int add_get_index_double(zval *arg, ulong idx, double d, void **dest);
+ZEND_API int add_get_index_string(zval *arg, ulong idx, char *str, void **dest, int duplicate);
+ZEND_API int add_get_index_stringl(zval *arg, ulong idx, char *str, uint length, void **dest, int duplicate);
ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long l TSRMLS_DC);
ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len TSRMLS_DC);

0 comments on commit b05b949

Please sign in to comment.