mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Use better data structures (incomplete)
This commit is contained in:
parent
40e053e7f3
commit
398256e5fe
14 changed files with 584 additions and 668 deletions
|
@ -604,6 +604,7 @@ END_EXTERN_C()
|
||||||
#define RETVAL_STRING(s) ZVAL_STRING(return_value, s)
|
#define RETVAL_STRING(s) ZVAL_STRING(return_value, s)
|
||||||
#define RETVAL_STRINGL(s, l) ZVAL_STRINGL(return_value, s, l)
|
#define RETVAL_STRINGL(s, l) ZVAL_STRINGL(return_value, s, l)
|
||||||
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
|
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
|
||||||
|
#define RETVAL_RES(r) ZVAL_RES(return_value, r)
|
||||||
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
|
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
|
||||||
#define RETVAL_FALSE ZVAL_BOOL(return_value, 0)
|
#define RETVAL_FALSE ZVAL_BOOL(return_value, 0)
|
||||||
#define RETVAL_TRUE ZVAL_BOOL(return_value, 1)
|
#define RETVAL_TRUE ZVAL_BOOL(return_value, 1)
|
||||||
|
@ -616,6 +617,7 @@ END_EXTERN_C()
|
||||||
#define RETURN_STRING(s) { RETVAL_STRING(s); return; }
|
#define RETURN_STRING(s) { RETVAL_STRING(s); return; }
|
||||||
#define RETURN_STRINGL(s, l) { RETVAL_STRINGL(s, l); return; }
|
#define RETURN_STRINGL(s, l) { RETVAL_STRINGL(s, l); return; }
|
||||||
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
|
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
|
||||||
|
#define RETURN_RES(r) { RETVAL_RES(r); return; }
|
||||||
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
|
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
|
||||||
#define RETURN_FALSE { RETVAL_FALSE; return; }
|
#define RETURN_FALSE { RETVAL_FALSE; return; }
|
||||||
#define RETURN_TRUE { RETVAL_TRUE; return; }
|
#define RETURN_TRUE { RETVAL_TRUE; return; }
|
||||||
|
|
|
@ -259,20 +259,20 @@ static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zv
|
||||||
if (filterparams != NULL) {
|
if (filterparams != NULL) {
|
||||||
if (Z_TYPE_P(filterparams) == IS_ARRAY) {
|
if (Z_TYPE_P(filterparams) == IS_ARRAY) {
|
||||||
HashPosition pos;
|
HashPosition pos;
|
||||||
zval **tmp;
|
zval *tmp;
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(filterparams), &pos);
|
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(filterparams), &pos);
|
||||||
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(filterparams), (void **) &tmp, &pos) == SUCCESS) {
|
while ((tmp = zend_hash_get_current_data_ex(Z_ARRVAL_P(filterparams), &pos)) != NULL) {
|
||||||
convert_to_string_ex(tmp);
|
convert_to_string_ex(tmp);
|
||||||
smart_str_appendc(&tags_ss, '<');
|
smart_str_appendc(&tags_ss, '<');
|
||||||
smart_str_appendl(&tags_ss, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
|
smart_str_appendl(&tags_ss, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
|
||||||
smart_str_appendc(&tags_ss, '>');
|
smart_str_appendc(&tags_ss, '>');
|
||||||
zend_hash_move_forward_ex(Z_ARRVAL_P(filterparams), &pos);
|
zend_hash_move_forward_ex(Z_ARRVAL_P(filterparams), &pos);
|
||||||
}
|
}
|
||||||
smart_str_0(&tags_ss);
|
smart_str_0(&tags_ss);
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: convert_to_* may clutter zvals and lead it into segfault ? */
|
/* FIXME: convert_to_* may clutter zvals and lead it into segfault ? */
|
||||||
convert_to_string_ex(&filterparams);
|
convert_to_string_ex(filterparams);
|
||||||
|
|
||||||
tags_ss.c = Z_STRVAL_P(filterparams);
|
tags_ss.c = Z_STRVAL_P(filterparams);
|
||||||
tags_ss.len = Z_STRLEN_P(filterparams);
|
tags_ss.len = Z_STRLEN_P(filterparams);
|
||||||
|
@ -282,14 +282,14 @@ static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zv
|
||||||
|
|
||||||
if (php_strip_tags_filter_ctor(inst, tags_ss.c, tags_ss.len, persistent) != SUCCESS) {
|
if (php_strip_tags_filter_ctor(inst, tags_ss.c, tags_ss.len, persistent) != SUCCESS) {
|
||||||
if (tags_ss.a != 0) {
|
if (tags_ss.a != 0) {
|
||||||
STR_FREE(tags_ss.c);
|
//??? STR_FREE(tags_ss.c);
|
||||||
}
|
}
|
||||||
pefree(inst, persistent);
|
pefree(inst, persistent);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags_ss.a != 0) {
|
if (tags_ss.a != 0) {
|
||||||
STR_FREE(tags_ss.c);
|
//??? STR_FREE(tags_ss.c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return php_stream_filter_alloc(&strfilter_strip_tags_ops, inst, persistent);
|
return php_stream_filter_alloc(&strfilter_strip_tags_ops, inst, persistent);
|
||||||
|
@ -1220,15 +1220,16 @@ typedef struct _php_convert_filter {
|
||||||
|
|
||||||
static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pretval, size_t *pretval_len, char *field_name, size_t field_name_len, int persistent)
|
static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pretval, size_t *pretval_len, char *field_name, size_t field_name_len, int persistent)
|
||||||
{
|
{
|
||||||
zval **tmpval;
|
zval *tmpval;
|
||||||
|
|
||||||
*pretval = NULL;
|
*pretval = NULL;
|
||||||
*pretval_len = 0;
|
*pretval_len = 0;
|
||||||
|
|
||||||
if (zend_hash_find((HashTable *)ht, field_name, field_name_len, (void **)&tmpval) == SUCCESS) {
|
if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) {
|
||||||
if (Z_TYPE_PP(tmpval) != IS_STRING) {
|
if (Z_TYPE_P(tmpval) != IS_STRING) {
|
||||||
zval zt = **tmpval;
|
zval zt;
|
||||||
|
|
||||||
|
ZVAL_COPY_VALUE(&zt, tmpval);
|
||||||
convert_to_string(&zt);
|
convert_to_string(&zt);
|
||||||
|
|
||||||
if (NULL == (*pretval = pemalloc(Z_STRLEN(zt) + 1, persistent))) {
|
if (NULL == (*pretval = pemalloc(Z_STRLEN(zt) + 1, persistent))) {
|
||||||
|
@ -1239,11 +1240,11 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr
|
||||||
memcpy(*pretval, Z_STRVAL(zt), Z_STRLEN(zt) + 1);
|
memcpy(*pretval, Z_STRVAL(zt), Z_STRLEN(zt) + 1);
|
||||||
zval_dtor(&zt);
|
zval_dtor(&zt);
|
||||||
} else {
|
} else {
|
||||||
if (NULL == (*pretval = pemalloc(Z_STRLEN_PP(tmpval) + 1, persistent))) {
|
if (NULL == (*pretval = pemalloc(Z_STRLEN_P(tmpval) + 1, persistent))) {
|
||||||
return PHP_CONV_ERR_ALLOC;
|
return PHP_CONV_ERR_ALLOC;
|
||||||
}
|
}
|
||||||
*pretval_len = Z_STRLEN_PP(tmpval);
|
*pretval_len = Z_STRLEN_P(tmpval);
|
||||||
memcpy(*pretval, Z_STRVAL_PP(tmpval), Z_STRLEN_PP(tmpval) + 1);
|
memcpy(*pretval, Z_STRVAL_P(tmpval), Z_STRLEN_P(tmpval) + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return PHP_CONV_ERR_NOT_FOUND;
|
return PHP_CONV_ERR_NOT_FOUND;
|
||||||
|
@ -1277,23 +1278,22 @@ static php_conv_err_t php_conv_get_long_prop_ex(const HashTable *ht, long *pretv
|
||||||
|
|
||||||
static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, unsigned long *pretval, char *field_name, size_t field_name_len)
|
static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, unsigned long *pretval, char *field_name, size_t field_name_len)
|
||||||
{
|
{
|
||||||
zval **tmpval;
|
zval *tmpval;
|
||||||
|
|
||||||
*pretval = 0;
|
*pretval = 0;
|
||||||
|
|
||||||
if (zend_hash_find((HashTable *)ht, field_name, field_name_len, (void **)&tmpval) == SUCCESS) {
|
if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) {
|
||||||
zval tmp, *ztval = *tmpval;
|
zval tmp;
|
||||||
|
|
||||||
if (Z_TYPE_PP(tmpval) != IS_LONG) {
|
if (Z_TYPE_P(tmpval) != IS_LONG) {
|
||||||
tmp = *ztval;
|
ZVAL_DUP(&tmp, tmpval);;
|
||||||
zval_copy_ctor(&tmp);
|
|
||||||
convert_to_long(&tmp);
|
convert_to_long(&tmp);
|
||||||
ztval = &tmp;
|
tmpval = &tmp;
|
||||||
}
|
}
|
||||||
if (Z_LVAL_P(ztval) < 0) {
|
if (Z_LVAL_P(tmpval) < 0) {
|
||||||
*pretval = 0;
|
*pretval = 0;
|
||||||
} else {
|
} else {
|
||||||
*pretval = Z_LVAL_P(ztval);
|
*pretval = Z_LVAL_P(tmpval);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return PHP_CONV_ERR_NOT_FOUND;
|
return PHP_CONV_ERR_NOT_FOUND;
|
||||||
|
@ -1303,20 +1303,20 @@ static php_conv_err_t php_conv_get_ulong_prop_ex(const HashTable *ht, unsigned l
|
||||||
|
|
||||||
static php_conv_err_t php_conv_get_bool_prop_ex(const HashTable *ht, int *pretval, char *field_name, size_t field_name_len)
|
static php_conv_err_t php_conv_get_bool_prop_ex(const HashTable *ht, int *pretval, char *field_name, size_t field_name_len)
|
||||||
{
|
{
|
||||||
zval **tmpval;
|
zval *tmpval;
|
||||||
|
|
||||||
*pretval = 0;
|
*pretval = 0;
|
||||||
|
|
||||||
if (zend_hash_find((HashTable *)ht, field_name, field_name_len, (void **)&tmpval) == SUCCESS) {
|
if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) {
|
||||||
zval tmp, *ztval = *tmpval;
|
zval tmp;
|
||||||
|
|
||||||
if (Z_TYPE_PP(tmpval) != IS_BOOL) {
|
if (Z_TYPE_P(tmpval) != IS_BOOL) {
|
||||||
tmp = *ztval;
|
ZVAL_DUP(&tmp, tmpval);
|
||||||
zval_copy_ctor(&tmp);
|
zval_copy_ctor(&tmp);
|
||||||
convert_to_boolean(&tmp);
|
convert_to_boolean(&tmp);
|
||||||
ztval = &tmp;
|
tmpval = &tmp;
|
||||||
}
|
}
|
||||||
*pretval = Z_BVAL_P(ztval);
|
*pretval = Z_BVAL_P(tmpval);
|
||||||
} else {
|
} else {
|
||||||
return PHP_CONV_ERR_NOT_FOUND;
|
return PHP_CONV_ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,11 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||||
const char *key_suffix, int key_suffix_len,
|
const char *key_suffix, int key_suffix_len,
|
||||||
zval *type, char *arg_sep, int enc_type TSRMLS_DC)
|
zval *type, char *arg_sep, int enc_type TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *key = NULL;
|
zend_string *key = NULL;
|
||||||
char *ekey, *newprefix, *p;
|
char *ekey, *newprefix, *p, *prop_name;
|
||||||
int arg_sep_len, ekey_len, key_type, newprefix_len;
|
int arg_sep_len, ekey_len, key_type, newprefix_len, prop_len;
|
||||||
uint key_len;
|
|
||||||
ulong idx;
|
ulong idx;
|
||||||
zval **zdata = NULL, *copyzval;
|
zval *zdata = NULL, copyzval;
|
||||||
|
|
||||||
if (!ht) {
|
if (!ht) {
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
@ -56,36 +55,34 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||||
arg_sep_len = strlen(arg_sep);
|
arg_sep_len = strlen(arg_sep);
|
||||||
|
|
||||||
for (zend_hash_internal_pointer_reset(ht);
|
for (zend_hash_internal_pointer_reset(ht);
|
||||||
(key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT;
|
(key_type = zend_hash_get_current_key_ex(ht, &key, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT;
|
||||||
zend_hash_move_forward(ht)
|
zend_hash_move_forward(ht)
|
||||||
) {
|
) {
|
||||||
if (key_type == HASH_KEY_IS_STRING && key_len && key[key_len-1] == '\0') {
|
|
||||||
/* We don't want that trailing NULL */
|
|
||||||
key_len -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* handling for private & protected object properties */
|
/* handling for private & protected object properties */
|
||||||
if (key && *key == '\0' && type != NULL) {
|
prop_name = key->val;
|
||||||
const char *tmp;
|
prop_len = key->len;
|
||||||
|
if (key && key->val[0] == '\0' && type != NULL) {
|
||||||
|
const char *tmp, *prop_name;
|
||||||
|
int prop_len;
|
||||||
|
|
||||||
zend_object *zobj = zend_objects_get_address(type TSRMLS_CC);
|
zend_object *zobj = Z_OBJ_P(type);
|
||||||
if (zend_check_property_access(zobj, key, key_len TSRMLS_CC) != SUCCESS) {
|
if (zend_check_property_access(zobj, key TSRMLS_CC) != SUCCESS) {
|
||||||
/* private or protected property access outside of the class */
|
/* private or protected property access outside of the class */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
zend_unmangle_property_name_ex(key, key_len, &tmp, (const char**)&key, &key_len);
|
zend_unmangle_property_name_ex(key->val, key->len, &tmp, &prop_name, &prop_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zend_hash_get_current_data_ex(ht, (void **)&zdata, NULL) == FAILURE || !zdata || !(*zdata)) {
|
if ((zdata = zend_hash_get_current_data_ex(ht, NULL)) == NULL) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error traversing form data array");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error traversing form data array");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
if (Z_TYPE_PP(zdata) == IS_ARRAY || Z_TYPE_PP(zdata) == IS_OBJECT) {
|
if (Z_TYPE_P(zdata) == IS_ARRAY || Z_TYPE_P(zdata) == IS_OBJECT) {
|
||||||
if (key_type == HASH_KEY_IS_STRING) {
|
if (key_type == HASH_KEY_IS_STRING) {
|
||||||
if (enc_type == PHP_QUERY_RFC3986) {
|
if (enc_type == PHP_QUERY_RFC3986) {
|
||||||
ekey = php_raw_url_encode(key, key_len, &ekey_len);
|
ekey = php_raw_url_encode(prop_name, prop_len, &ekey_len);
|
||||||
} else {
|
} else {
|
||||||
ekey = php_url_encode(key, key_len, &ekey_len);
|
ekey = php_url_encode(prop_name, prop_len, &ekey_len);
|
||||||
}
|
}
|
||||||
newprefix_len = key_suffix_len + ekey_len + key_prefix_len + 3 /* %5B */;
|
newprefix_len = key_suffix_len + ekey_len + key_prefix_len + 3 /* %5B */;
|
||||||
newprefix = emalloc(newprefix_len + 1);
|
newprefix = emalloc(newprefix_len + 1);
|
||||||
|
@ -137,10 +134,10 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
ht->nApplyCount++;
|
ht->nApplyCount++;
|
||||||
php_url_encode_hash_ex(HASH_OF(*zdata), formstr, NULL, 0, newprefix, newprefix_len, "%5D", 3, (Z_TYPE_PP(zdata) == IS_OBJECT ? *zdata : NULL), arg_sep, enc_type TSRMLS_CC);
|
php_url_encode_hash_ex(HASH_OF(zdata), formstr, NULL, 0, newprefix, newprefix_len, "%5D", 3, (Z_TYPE_P(zdata) == IS_OBJECT ? zdata : NULL), arg_sep, enc_type TSRMLS_CC);
|
||||||
ht->nApplyCount--;
|
ht->nApplyCount--;
|
||||||
efree(newprefix);
|
efree(newprefix);
|
||||||
} else if (Z_TYPE_PP(zdata) == IS_NULL || Z_TYPE_PP(zdata) == IS_RESOURCE) {
|
} else if (Z_TYPE_P(zdata) == IS_NULL || Z_TYPE_P(zdata) == IS_RESOURCE) {
|
||||||
/* Skip these types */
|
/* Skip these types */
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,9 +148,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||||
smart_str_appendl(formstr, key_prefix, key_prefix_len);
|
smart_str_appendl(formstr, key_prefix, key_prefix_len);
|
||||||
if (key_type == HASH_KEY_IS_STRING) {
|
if (key_type == HASH_KEY_IS_STRING) {
|
||||||
if (enc_type == PHP_QUERY_RFC3986) {
|
if (enc_type == PHP_QUERY_RFC3986) {
|
||||||
ekey = php_raw_url_encode(key, key_len, &ekey_len);
|
ekey = php_raw_url_encode(prop_name, prop_len, &ekey_len);
|
||||||
} else {
|
} else {
|
||||||
ekey = php_url_encode(key, key_len, &ekey_len);
|
ekey = php_url_encode(prop_name, prop_len, &ekey_len);
|
||||||
}
|
}
|
||||||
smart_str_appendl(formstr, ekey, ekey_len);
|
smart_str_appendl(formstr, ekey, ekey_len);
|
||||||
efree(ekey);
|
efree(ekey);
|
||||||
|
@ -168,31 +165,29 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||||
}
|
}
|
||||||
smart_str_appendl(formstr, key_suffix, key_suffix_len);
|
smart_str_appendl(formstr, key_suffix, key_suffix_len);
|
||||||
smart_str_appendl(formstr, "=", 1);
|
smart_str_appendl(formstr, "=", 1);
|
||||||
switch (Z_TYPE_PP(zdata)) {
|
switch (Z_TYPE_P(zdata)) {
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
if (enc_type == PHP_QUERY_RFC3986) {
|
if (enc_type == PHP_QUERY_RFC3986) {
|
||||||
ekey = php_raw_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len);
|
ekey = php_raw_url_encode(Z_STRVAL_P(zdata), Z_STRLEN_P(zdata), &ekey_len);
|
||||||
} else {
|
} else {
|
||||||
ekey = php_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len);
|
ekey = php_url_encode(Z_STRVAL_P(zdata), Z_STRLEN_P(zdata), &ekey_len);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
case IS_BOOL:
|
case IS_BOOL:
|
||||||
ekey_len = spprintf(&ekey, 0, "%ld", Z_LVAL_PP(zdata));
|
ekey_len = spprintf(&ekey, 0, "%ld", Z_LVAL_P(zdata));
|
||||||
break;
|
break;
|
||||||
case IS_DOUBLE:
|
case IS_DOUBLE:
|
||||||
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_PP(zdata));
|
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_P(zdata));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* fall back on convert to string */
|
/* fall back on convert to string */
|
||||||
MAKE_STD_ZVAL(copyzval);
|
ZVAL_DUP(©zval, zdata);
|
||||||
*copyzval = **zdata;
|
|
||||||
zval_copy_ctor(copyzval);
|
|
||||||
convert_to_string_ex(©zval);
|
convert_to_string_ex(©zval);
|
||||||
if (enc_type == PHP_QUERY_RFC3986) {
|
if (enc_type == PHP_QUERY_RFC3986) {
|
||||||
ekey = php_raw_url_encode(Z_STRVAL_P(copyzval), Z_STRLEN_P(copyzval), &ekey_len);
|
ekey = php_raw_url_encode(Z_STRVAL(copyzval), Z_STRLEN(copyzval), &ekey_len);
|
||||||
} else {
|
} else {
|
||||||
ekey = php_url_encode(Z_STRVAL_P(copyzval), Z_STRLEN_P(copyzval), &ekey_len);
|
ekey = php_url_encode(Z_STRVAL(copyzval), Z_STRLEN(copyzval), &ekey_len);
|
||||||
}
|
}
|
||||||
zval_ptr_dtor(©zval);
|
zval_ptr_dtor(©zval);
|
||||||
}
|
}
|
||||||
|
@ -237,7 +232,8 @@ PHP_FUNCTION(http_build_query)
|
||||||
|
|
||||||
smart_str_0(&formstr);
|
smart_str_0(&formstr);
|
||||||
|
|
||||||
RETURN_STRINGL(formstr.c, formstr.len, 0);
|
//??? RETURN_STRINGL(formstr.c, formstr.len, 0);
|
||||||
|
RETURN_STRINGL(formstr.c, formstr.len);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ PHP_FUNCTION(password_get_info)
|
||||||
php_password_algo algo;
|
php_password_algo algo;
|
||||||
int hash_len;
|
int hash_len;
|
||||||
char *hash, *algo_name;
|
char *hash, *algo_name;
|
||||||
zval *options;
|
zval options;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hash, &hash_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hash, &hash_len) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
|
@ -188,8 +188,7 @@ PHP_FUNCTION(password_get_info)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(options);
|
array_init(&options);
|
||||||
array_init(options);
|
|
||||||
|
|
||||||
algo = php_password_determine_algo(hash, (size_t) hash_len);
|
algo = php_password_determine_algo(hash, (size_t) hash_len);
|
||||||
algo_name = php_password_get_algo_name(algo);
|
algo_name = php_password_get_algo_name(algo);
|
||||||
|
@ -199,7 +198,7 @@ PHP_FUNCTION(password_get_info)
|
||||||
{
|
{
|
||||||
long cost = PHP_PASSWORD_BCRYPT_COST;
|
long cost = PHP_PASSWORD_BCRYPT_COST;
|
||||||
sscanf(hash, "$2y$%ld$", &cost);
|
sscanf(hash, "$2y$%ld$", &cost);
|
||||||
add_assoc_long(options, "cost", cost);
|
add_assoc_long(&options, "cost", cost);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHP_PASSWORD_UNKNOWN:
|
case PHP_PASSWORD_UNKNOWN:
|
||||||
|
@ -211,7 +210,7 @@ PHP_FUNCTION(password_get_info)
|
||||||
|
|
||||||
add_assoc_long(return_value, "algo", algo);
|
add_assoc_long(return_value, "algo", algo);
|
||||||
add_assoc_string(return_value, "algoName", algo_name, 1);
|
add_assoc_string(return_value, "algoName", algo_name, 1);
|
||||||
add_assoc_zval(return_value, "options", options);
|
add_assoc_zval(return_value, "options", &options);
|
||||||
}
|
}
|
||||||
|
|
||||||
PHP_FUNCTION(password_needs_rehash)
|
PHP_FUNCTION(password_needs_rehash)
|
||||||
|
@ -221,7 +220,7 @@ PHP_FUNCTION(password_needs_rehash)
|
||||||
int hash_len;
|
int hash_len;
|
||||||
char *hash;
|
char *hash;
|
||||||
HashTable *options = 0;
|
HashTable *options = 0;
|
||||||
zval **option_buffer;
|
zval *option_buffer;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
|
@ -243,15 +242,15 @@ PHP_FUNCTION(password_needs_rehash)
|
||||||
{
|
{
|
||||||
long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
|
long new_cost = PHP_PASSWORD_BCRYPT_COST, cost = 0;
|
||||||
|
|
||||||
if (options && zend_symtable_find(options, "cost", sizeof("cost"), (void **) &option_buffer) == SUCCESS) {
|
if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) {
|
||||||
if (Z_TYPE_PP(option_buffer) != IS_LONG) {
|
if (Z_TYPE_P(option_buffer) != IS_LONG) {
|
||||||
zval cast_option_buffer;
|
zval cast_option_buffer;
|
||||||
MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer);
|
ZVAL_DUP(&cast_option_buffer, option_buffer);
|
||||||
convert_to_long(&cast_option_buffer);
|
convert_to_long(&cast_option_buffer);
|
||||||
new_cost = Z_LVAL(cast_option_buffer);
|
new_cost = Z_LVAL(cast_option_buffer);
|
||||||
zval_dtor(&cast_option_buffer);
|
zval_dtor(&cast_option_buffer);
|
||||||
} else {
|
} else {
|
||||||
new_cost = Z_LVAL_PP(option_buffer);
|
new_cost = Z_LVAL_P(option_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +311,7 @@ PHP_FUNCTION(password_hash)
|
||||||
int password_len = 0, hash_len;
|
int password_len = 0, hash_len;
|
||||||
size_t salt_len = 0, required_salt_len = 0, hash_format_len;
|
size_t salt_len = 0, required_salt_len = 0, hash_format_len;
|
||||||
HashTable *options = 0;
|
HashTable *options = 0;
|
||||||
zval **option_buffer;
|
zval *option_buffer;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &password, &password_len, &algo, &options) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|H", &password, &password_len, &algo, &options) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
|
@ -323,15 +322,15 @@ PHP_FUNCTION(password_hash)
|
||||||
{
|
{
|
||||||
long cost = PHP_PASSWORD_BCRYPT_COST;
|
long cost = PHP_PASSWORD_BCRYPT_COST;
|
||||||
|
|
||||||
if (options && zend_symtable_find(options, "cost", 5, (void **) &option_buffer) == SUCCESS) {
|
if (options && (option_buffer = zend_symtable_str_find(options, "cost", sizeof("cost")-1)) != NULL) {
|
||||||
if (Z_TYPE_PP(option_buffer) != IS_LONG) {
|
if (Z_TYPE_P(option_buffer) != IS_LONG) {
|
||||||
zval cast_option_buffer;
|
zval cast_option_buffer;
|
||||||
MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer);
|
ZVAL_DUP(&cast_option_buffer, option_buffer);
|
||||||
convert_to_long(&cast_option_buffer);
|
convert_to_long(&cast_option_buffer);
|
||||||
cost = Z_LVAL(cast_option_buffer);
|
cost = Z_LVAL(cast_option_buffer);
|
||||||
zval_dtor(&cast_option_buffer);
|
zval_dtor(&cast_option_buffer);
|
||||||
} else {
|
} else {
|
||||||
cost = Z_LVAL_PP(option_buffer);
|
cost = Z_LVAL_P(option_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,20 +351,21 @@ PHP_FUNCTION(password_hash)
|
||||||
RETURN_NULL();
|
RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options && zend_symtable_find(options, "salt", 5, (void**) &option_buffer) == SUCCESS) {
|
if (options && (option_buffer = zend_symtable_str_find(options, "salt", sizeof("salt")-1)) != NULL) {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int buffer_len_int = 0;
|
int buffer_len_int = 0;
|
||||||
size_t buffer_len;
|
size_t buffer_len;
|
||||||
switch (Z_TYPE_PP(option_buffer)) {
|
switch (Z_TYPE_P(option_buffer)) {
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
buffer = estrndup(Z_STRVAL_PP(option_buffer), Z_STRLEN_PP(option_buffer));
|
buffer = estrndup(Z_STRVAL_P(option_buffer), Z_STRLEN_P(option_buffer));
|
||||||
buffer_len_int = Z_STRLEN_PP(option_buffer);
|
buffer_len_int = Z_STRLEN_P(option_buffer);
|
||||||
break;
|
break;
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
case IS_DOUBLE:
|
case IS_DOUBLE:
|
||||||
case IS_OBJECT: {
|
case IS_OBJECT: {
|
||||||
zval cast_option_buffer;
|
zval cast_option_buffer;
|
||||||
MAKE_COPY_ZVAL(option_buffer, &cast_option_buffer);
|
|
||||||
|
ZVAL_DUP(&cast_option_buffer, option_buffer);
|
||||||
convert_to_string(&cast_option_buffer);
|
convert_to_string(&cast_option_buffer);
|
||||||
if (Z_TYPE(cast_option_buffer) == IS_STRING) {
|
if (Z_TYPE(cast_option_buffer) == IS_STRING) {
|
||||||
buffer = estrndup(Z_STRVAL(cast_option_buffer), Z_STRLEN(cast_option_buffer));
|
buffer = estrndup(Z_STRVAL(cast_option_buffer), Z_STRLEN(cast_option_buffer));
|
||||||
|
@ -445,7 +445,8 @@ PHP_FUNCTION(password_hash)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STRING(result, 0);
|
//??? RETURN_STRING(result, 0);
|
||||||
|
RETURN_STRING(result);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ struct php_unserialize_data {
|
||||||
|
|
||||||
typedef struct php_unserialize_data* php_unserialize_data_t;
|
typedef struct php_unserialize_data* php_unserialize_data_t;
|
||||||
|
|
||||||
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC);
|
PHPAPI void php_var_serialize(smart_str *buf, zval *struc, php_serialize_data_t *var_hash TSRMLS_DC);
|
||||||
PHPAPI int php_var_unserialize(zval **rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC);
|
PHPAPI int php_var_unserialize(zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC);
|
||||||
|
|
||||||
#define PHP_VAR_SERIALIZE_INIT(var_hash_ptr) \
|
#define PHP_VAR_SERIALIZE_INIT(var_hash_ptr) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -113,9 +113,9 @@ do { \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
PHPAPI void var_replace(php_unserialize_data_t *var_hash, zval *ozval, zval **nzval);
|
PHPAPI void var_replace(php_unserialize_data_t *var_hash, zval *ozval, zval *nzval);
|
||||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hash, zval **val);
|
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hash, zval *val);
|
||||||
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval);
|
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rval);
|
||||||
PHPAPI void var_destroy(php_unserialize_data_t *var_hash);
|
PHPAPI void var_destroy(php_unserialize_data_t *var_hash);
|
||||||
|
|
||||||
#define PHP_VAR_UNSERIALIZE_ZVAL_CHANGED(var_hash, ozval, nzval) \
|
#define PHP_VAR_UNSERIALIZE_ZVAL_CHANGED(var_hash, ozval, nzval) \
|
||||||
|
|
|
@ -74,14 +74,15 @@ static int le_proc_open;
|
||||||
/* {{{ _php_array_to_envp */
|
/* {{{ _php_array_to_envp */
|
||||||
static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent TSRMLS_DC)
|
static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **element;
|
zval *element;
|
||||||
php_process_env_t env;
|
php_process_env_t env;
|
||||||
char *string_key, *data;
|
zend_string *string_key;
|
||||||
|
char *data;
|
||||||
#ifndef PHP_WIN32
|
#ifndef PHP_WIN32
|
||||||
char **ep;
|
char **ep;
|
||||||
#endif
|
#endif
|
||||||
char *p;
|
char *p;
|
||||||
uint string_length, cnt, l, sizeenv=0, el_len;
|
uint cnt, l, sizeenv=0, el_len;
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
HashTable *target_hash;
|
HashTable *target_hash;
|
||||||
HashPosition pos;
|
HashPosition pos;
|
||||||
|
@ -109,23 +110,23 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||||
|
|
||||||
/* first, we have to get the size of all the elements in the hash */
|
/* first, we have to get the size of all the elements in the hash */
|
||||||
for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
|
for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
|
||||||
zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
|
(element = zend_hash_get_current_data_ex(target_hash, &pos)) != NULL;
|
||||||
zend_hash_move_forward_ex(target_hash, &pos)) {
|
zend_hash_move_forward_ex(target_hash, &pos)) {
|
||||||
|
|
||||||
convert_to_string_ex(element);
|
convert_to_string_ex(element);
|
||||||
el_len = Z_STRLEN_PP(element);
|
el_len = Z_STRLEN_P(element);
|
||||||
if (el_len == 0) {
|
if (el_len == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeenv += el_len+1;
|
sizeenv += el_len+1;
|
||||||
|
|
||||||
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) {
|
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &num_key, 0, &pos)) {
|
||||||
case HASH_KEY_IS_STRING:
|
case HASH_KEY_IS_STRING:
|
||||||
if (string_length == 0) {
|
if (string_key->len == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sizeenv += string_length+1;
|
sizeenv += string_key->len + 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,25 +137,25 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
|
||||||
p = env.envp = (char *) pecalloc(sizeenv + 4, 1, is_persistent);
|
p = env.envp = (char *) pecalloc(sizeenv + 4, 1, is_persistent);
|
||||||
|
|
||||||
for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
|
for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
|
||||||
zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
|
(element = zend_hash_get_current_data_ex(target_hash, &pos)) != NULL;
|
||||||
zend_hash_move_forward_ex(target_hash, &pos)) {
|
zend_hash_move_forward_ex(target_hash, &pos)) {
|
||||||
|
|
||||||
convert_to_string_ex(element);
|
convert_to_string_ex(element);
|
||||||
el_len = Z_STRLEN_PP(element);
|
el_len = Z_STRLEN_P(element);
|
||||||
|
|
||||||
if (el_len == 0) {
|
if (el_len == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = Z_STRVAL_PP(element);
|
data = Z_STRVAL_P(element);
|
||||||
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) {
|
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &num_key, 0, &pos)) {
|
||||||
case HASH_KEY_IS_STRING:
|
case HASH_KEY_IS_STRING:
|
||||||
if (string_length == 0) {
|
if (string_key->len == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = string_length + el_len + 1;
|
l = string_key->len + el_len + 2;
|
||||||
memcpy(p, string_key, string_length);
|
memcpy(p, string_key->val, string_key->len);
|
||||||
strncat(p, "=", 1);
|
strncat(p, "=", 1);
|
||||||
strncat(p, data, el_len);
|
strncat(p, data, el_len);
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ static void _php_free_envp(php_process_env_t env, int is_persistent)
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proc_open_rsrc_dtor */
|
/* {{{ proc_open_rsrc_dtor */
|
||||||
static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void proc_open_rsrc_dtor(zend_resource *rsrc TSRMLS_DC)
|
||||||
{
|
{
|
||||||
struct php_process_handle *proc = (struct php_process_handle*)rsrc->ptr;
|
struct php_process_handle *proc = (struct php_process_handle*)rsrc->ptr;
|
||||||
int i;
|
int i;
|
||||||
|
@ -279,7 +280,7 @@ PHP_FUNCTION(proc_terminate)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
|
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
if (TerminateProcess(proc->childHandle, 255)) {
|
if (TerminateProcess(proc->childHandle, 255)) {
|
||||||
|
@ -308,10 +309,10 @@ PHP_FUNCTION(proc_close)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
|
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||||
|
|
||||||
FG(pclose_wait) = 1;
|
FG(pclose_wait) = 1;
|
||||||
zend_list_delete(Z_LVAL_P(zproc));
|
zend_list_delete(Z_RES_P(zproc));
|
||||||
FG(pclose_wait) = 0;
|
FG(pclose_wait) = 0;
|
||||||
RETURN_LONG(FG(pclose_ret));
|
RETURN_LONG(FG(pclose_ret));
|
||||||
}
|
}
|
||||||
|
@ -336,7 +337,7 @@ PHP_FUNCTION(proc_get_status)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
|
ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, "process", le_proc_open);
|
||||||
|
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
|
|
||||||
|
@ -438,7 +439,7 @@ PHP_FUNCTION(proc_open)
|
||||||
php_process_env_t env;
|
php_process_env_t env;
|
||||||
int ndesc = 0;
|
int ndesc = 0;
|
||||||
int i;
|
int i;
|
||||||
zval **descitem = NULL;
|
zval *descitem = NULL;
|
||||||
HashPosition pos;
|
HashPosition pos;
|
||||||
struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
|
@ -517,13 +518,13 @@ PHP_FUNCTION(proc_open)
|
||||||
|
|
||||||
/* walk the descriptor spec and set up files/pipes */
|
/* walk the descriptor spec and set up files/pipes */
|
||||||
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(descriptorspec), &pos);
|
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(descriptorspec), &pos);
|
||||||
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(descriptorspec), (void **)&descitem, &pos) == SUCCESS) {
|
while ((descitem = zend_hash_get_current_data_ex(Z_ARRVAL_P(descriptorspec), &pos)) != NULL) {
|
||||||
char *str_index;
|
zend_string *str_index;
|
||||||
ulong nindex;
|
ulong nindex;
|
||||||
zval **ztype;
|
zval *ztype;
|
||||||
|
|
||||||
str_index = NULL;
|
str_index = NULL;
|
||||||
zend_hash_get_current_key_ex(Z_ARRVAL_P(descriptorspec), &str_index, NULL, &nindex, 0, &pos);
|
zend_hash_get_current_key_ex(Z_ARRVAL_P(descriptorspec), &str_index, &nindex, 0, &pos);
|
||||||
|
|
||||||
if (str_index) {
|
if (str_index) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "descriptor spec must be an integer indexed array");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "descriptor spec must be an integer indexed array");
|
||||||
|
@ -532,7 +533,7 @@ PHP_FUNCTION(proc_open)
|
||||||
|
|
||||||
descriptors[ndesc].index = nindex;
|
descriptors[ndesc].index = nindex;
|
||||||
|
|
||||||
if (Z_TYPE_PP(descitem) == IS_RESOURCE) {
|
if (Z_TYPE_P(descitem) == IS_RESOURCE) {
|
||||||
/* should be a stream - try and dup the descriptor */
|
/* should be a stream - try and dup the descriptor */
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -558,23 +559,23 @@ PHP_FUNCTION(proc_open)
|
||||||
#endif
|
#endif
|
||||||
descriptors[ndesc].mode = DESC_FILE;
|
descriptors[ndesc].mode = DESC_FILE;
|
||||||
|
|
||||||
} else if (Z_TYPE_PP(descitem) != IS_ARRAY) {
|
} else if (Z_TYPE_P(descitem) != IS_ARRAY) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Descriptor item must be either an array or a File-Handle");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Descriptor item must be either an array or a File-Handle");
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 0, (void **)&ztype) == SUCCESS) {
|
if ((ztype = zend_hash_index_find(Z_ARRVAL_P(descitem), 0)) != NULL) {
|
||||||
convert_to_string_ex(ztype);
|
convert_to_string_ex(ztype);
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing handle qualifier in array");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing handle qualifier in array");
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(Z_STRVAL_PP(ztype), "pipe") == 0) {
|
if (strcmp(Z_STRVAL_P(ztype), "pipe") == 0) {
|
||||||
php_file_descriptor_t newpipe[2];
|
php_file_descriptor_t newpipe[2];
|
||||||
zval **zmode;
|
zval *zmode;
|
||||||
|
|
||||||
if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zmode) == SUCCESS) {
|
if ((zmode = zend_hash_index_find(Z_ARRVAL_P(descitem), 1)) != NULL) {
|
||||||
convert_to_string_ex(zmode);
|
convert_to_string_ex(zmode);
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing mode parameter for 'pipe'");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing mode parameter for 'pipe'");
|
||||||
|
@ -588,7 +589,7 @@ PHP_FUNCTION(proc_open)
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(Z_STRVAL_PP(zmode), "w", 1) != 0) {
|
if (strncmp(Z_STRVAL_P(zmode), "w", 1) != 0) {
|
||||||
descriptors[ndesc].parentend = newpipe[1];
|
descriptors[ndesc].parentend = newpipe[1];
|
||||||
descriptors[ndesc].childend = newpipe[0];
|
descriptors[ndesc].childend = newpipe[0];
|
||||||
descriptors[ndesc].mode |= DESC_PARENT_MODE_WRITE;
|
descriptors[ndesc].mode |= DESC_PARENT_MODE_WRITE;
|
||||||
|
@ -602,25 +603,25 @@ PHP_FUNCTION(proc_open)
|
||||||
#endif
|
#endif
|
||||||
descriptors[ndesc].mode_flags = descriptors[ndesc].mode & DESC_PARENT_MODE_WRITE ? O_WRONLY : O_RDONLY;
|
descriptors[ndesc].mode_flags = descriptors[ndesc].mode & DESC_PARENT_MODE_WRITE ? O_WRONLY : O_RDONLY;
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
if (Z_STRLEN_PP(zmode) >= 2 && Z_STRVAL_PP(zmode)[1] == 'b')
|
if (Z_STRLEN_P(zmode) >= 2 && Z_STRVAL_P(zmode)[1] == 'b')
|
||||||
descriptors[ndesc].mode_flags |= O_BINARY;
|
descriptors[ndesc].mode_flags |= O_BINARY;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} else if (strcmp(Z_STRVAL_PP(ztype), "file") == 0) {
|
} else if (strcmp(Z_STRVAL_P(ztype), "file") == 0) {
|
||||||
zval **zfile, **zmode;
|
zval *zfile, *zmode;
|
||||||
int fd;
|
int fd;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
|
|
||||||
descriptors[ndesc].mode = DESC_FILE;
|
descriptors[ndesc].mode = DESC_FILE;
|
||||||
|
|
||||||
if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zfile) == SUCCESS) {
|
if ((zfile = zend_hash_index_find(Z_ARRVAL_P(descitem), 1)) != NULL) {
|
||||||
convert_to_string_ex(zfile);
|
convert_to_string_ex(zfile);
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing file name parameter for 'file'");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing file name parameter for 'file'");
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 2, (void **)&zmode) == SUCCESS) {
|
if ((zmode = zend_hash_index_find(Z_ARRVAL_P(descitem), 2)) != NULL) {
|
||||||
convert_to_string_ex(zmode);
|
convert_to_string_ex(zmode);
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing mode parameter for 'file'");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing mode parameter for 'file'");
|
||||||
|
@ -628,7 +629,7 @@ PHP_FUNCTION(proc_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try a wrapper */
|
/* try a wrapper */
|
||||||
stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), Z_STRVAL_PP(zmode),
|
stream = php_stream_open_wrapper(Z_STRVAL_P(zfile), Z_STRVAL_P(zmode),
|
||||||
REPORT_ERRORS|STREAM_WILL_CAST, NULL);
|
REPORT_ERRORS|STREAM_WILL_CAST, NULL);
|
||||||
|
|
||||||
/* force into an fd */
|
/* force into an fd */
|
||||||
|
@ -650,7 +651,7 @@ PHP_FUNCTION(proc_open)
|
||||||
#else
|
#else
|
||||||
descriptors[ndesc].childend = fd;
|
descriptors[ndesc].childend = fd;
|
||||||
#endif
|
#endif
|
||||||
} else if (strcmp(Z_STRVAL_PP(ztype), "pty") == 0) {
|
} else if (strcmp(Z_STRVAL_P(ztype), "pty") == 0) {
|
||||||
#if PHP_CAN_DO_PTS
|
#if PHP_CAN_DO_PTS
|
||||||
if (dev_ptmx == -1) {
|
if (dev_ptmx == -1) {
|
||||||
/* open things up */
|
/* open things up */
|
||||||
|
@ -677,7 +678,7 @@ PHP_FUNCTION(proc_open)
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a valid descriptor spec/mode", Z_STRVAL_PP(ztype));
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a valid descriptor spec/mode", Z_STRVAL_P(ztype));
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,20 +948,19 @@ PHP_FUNCTION(proc_open)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
if (stream) {
|
if (stream) {
|
||||||
zval *retfp;
|
zval retfp;
|
||||||
|
|
||||||
/* nasty hack; don't copy it */
|
/* nasty hack; don't copy it */
|
||||||
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
|
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
|
||||||
|
|
||||||
MAKE_STD_ZVAL(retfp);
|
php_stream_to_zval(stream, &retfp);
|
||||||
php_stream_to_zval(stream, retfp);
|
add_index_zval(pipes, descriptors[i].index, &retfp);
|
||||||
add_index_zval(pipes, descriptors[i].index, retfp);
|
|
||||||
|
|
||||||
proc->pipes[i] = Z_LVAL_P(retfp);
|
proc->pipes[i] = Z_RES_P(&retfp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
proc->pipes[i] = 0;
|
proc->pipes[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct php_process_handle {
|
||||||
HANDLE childHandle;
|
HANDLE childHandle;
|
||||||
#endif
|
#endif
|
||||||
int npipes;
|
int npipes;
|
||||||
long pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
zend_resource *pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
||||||
char *command;
|
char *command;
|
||||||
int is_persistent;
|
int is_persistent;
|
||||||
php_process_env_t env;
|
php_process_env_t env;
|
||||||
|
|
|
@ -75,8 +75,8 @@ PHP_FUNCTION(stream_socket_pair)
|
||||||
php_stream_auto_cleanup(s1);
|
php_stream_auto_cleanup(s1);
|
||||||
php_stream_auto_cleanup(s2);
|
php_stream_auto_cleanup(s2);
|
||||||
|
|
||||||
add_next_index_resource(return_value, php_stream_get_resource_id(s1));
|
add_next_index_resource(return_value, s1->res);
|
||||||
add_next_index_resource(return_value, php_stream_get_resource_id(s2));
|
add_next_index_resource(return_value, s2->res);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
#endif
|
#endif
|
||||||
|
@ -125,7 +125,7 @@ PHP_FUNCTION(stream_socket_client)
|
||||||
}
|
}
|
||||||
if (zerrstr) {
|
if (zerrstr) {
|
||||||
zval_dtor(zerrstr);
|
zval_dtor(zerrstr);
|
||||||
ZVAL_STRING(zerrstr, "", 1);
|
ZVAL_EMPTY_STRING(zerrstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
|
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
|
||||||
|
@ -154,7 +154,8 @@ PHP_FUNCTION(stream_socket_client)
|
||||||
if (zerrstr && errstr) {
|
if (zerrstr && errstr) {
|
||||||
/* no need to dup; we need to efree buf anyway */
|
/* no need to dup; we need to efree buf anyway */
|
||||||
zval_dtor(zerrstr);
|
zval_dtor(zerrstr);
|
||||||
ZVAL_STRING(zerrstr, errstr, 0);
|
//??? ZVAL_STRING(zerrstr, errstr, 0);
|
||||||
|
ZVAL_STRING(zerrstr, errstr);
|
||||||
} else if (errstr) {
|
} else if (errstr) {
|
||||||
efree(errstr);
|
efree(errstr);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ PHP_FUNCTION(stream_socket_server)
|
||||||
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
|
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
if (context) {
|
if (context) {
|
||||||
zend_list_addref(context->rsrc_id);
|
context->res->gc.refcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zerrno) {
|
if (zerrno) {
|
||||||
|
@ -201,7 +202,7 @@ PHP_FUNCTION(stream_socket_server)
|
||||||
}
|
}
|
||||||
if (zerrstr) {
|
if (zerrstr) {
|
||||||
zval_dtor(zerrstr);
|
zval_dtor(zerrstr);
|
||||||
ZVAL_STRING(zerrstr, "", 1);
|
ZVAL_EMPTY_STRING(zerrstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
|
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
|
||||||
|
@ -220,7 +221,8 @@ PHP_FUNCTION(stream_socket_server)
|
||||||
if (zerrstr && errstr) {
|
if (zerrstr && errstr) {
|
||||||
/* no need to dup; we need to efree buf anyway */
|
/* no need to dup; we need to efree buf anyway */
|
||||||
zval_dtor(zerrstr);
|
zval_dtor(zerrstr);
|
||||||
ZVAL_STRING(zerrstr, errstr, 0);
|
//??? ZVAL_STRING(zerrstr, errstr, 0);
|
||||||
|
ZVAL_STRING(zerrstr, errstr);
|
||||||
} else if (errstr) {
|
} else if (errstr) {
|
||||||
efree(errstr);
|
efree(errstr);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +256,7 @@ PHP_FUNCTION(stream_socket_accept)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
/* prepare the timeout value for use */
|
/* prepare the timeout value for use */
|
||||||
conv = (php_timeout_ull) (timeout * 1000000.0);
|
conv = (php_timeout_ull) (timeout * 1000000.0);
|
||||||
|
@ -278,7 +280,8 @@ PHP_FUNCTION(stream_socket_accept)
|
||||||
TSRMLS_CC) && clistream) {
|
TSRMLS_CC) && clistream) {
|
||||||
|
|
||||||
if (peername) {
|
if (peername) {
|
||||||
ZVAL_STRINGL(zpeername, peername, peername_len, 0);
|
//??? ZVAL_STRINGL(zpeername, peername, peername_len, 0);
|
||||||
|
ZVAL_STRINGL(zpeername, peername, peername_len);
|
||||||
}
|
}
|
||||||
php_stream_to_zval(clistream, return_value);
|
php_stream_to_zval(clistream, return_value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -306,7 +309,7 @@ PHP_FUNCTION(stream_socket_get_name)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if (0 != php_stream_xport_get_name(stream, want_peer,
|
if (0 != php_stream_xport_get_name(stream, want_peer,
|
||||||
&name,
|
&name,
|
||||||
|
@ -316,7 +319,8 @@ PHP_FUNCTION(stream_socket_get_name)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STRINGL(name, name_len, 0);
|
//??? RETURN_STRINGL(name, name_len, 0);
|
||||||
|
RETURN_STRINGL(name, name_len);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -335,7 +339,7 @@ PHP_FUNCTION(stream_socket_sendto)
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|ls", &zstream, &data, &datalen, &flags, &target_addr, &target_addr_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|ls", &zstream, &data, &datalen, &flags, &target_addr, &target_addr_len) == FAILURE) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if (target_addr_len) {
|
if (target_addr_len) {
|
||||||
/* parse the address */
|
/* parse the address */
|
||||||
|
@ -358,7 +362,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
|
||||||
char *remote_addr = NULL;
|
char *remote_addr = NULL;
|
||||||
int remote_addr_len;
|
int remote_addr_len;
|
||||||
long to_read = 0;
|
long to_read = 0;
|
||||||
char *read_buf;
|
zend_string *read_buf;
|
||||||
long flags = 0;
|
long flags = 0;
|
||||||
int recvd;
|
int recvd;
|
||||||
|
|
||||||
|
@ -366,7 +370,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if (zremote) {
|
if (zremote) {
|
||||||
zval_dtor(zremote);
|
zval_dtor(zremote);
|
||||||
|
@ -378,23 +382,24 @@ PHP_FUNCTION(stream_socket_recvfrom)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_buf = safe_emalloc(1, to_read, 1);
|
read_buf = STR_ALLOC(to_read, 0);
|
||||||
|
|
||||||
recvd = php_stream_xport_recvfrom(stream, read_buf, to_read, flags, NULL, NULL,
|
recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, flags, NULL, NULL,
|
||||||
zremote ? &remote_addr : NULL,
|
zremote ? &remote_addr : NULL,
|
||||||
zremote ? &remote_addr_len : NULL
|
zremote ? &remote_addr_len : NULL
|
||||||
TSRMLS_CC);
|
TSRMLS_CC);
|
||||||
|
|
||||||
if (recvd >= 0) {
|
if (recvd >= 0) {
|
||||||
if (zremote) {
|
if (zremote) {
|
||||||
ZVAL_STRINGL(zremote, remote_addr, remote_addr_len, 0);
|
//??? ZVAL_STRINGL(zremote, remote_addr, remote_addr_len, 0);
|
||||||
|
ZVAL_STRINGL(zremote, remote_addr, remote_addr_len);
|
||||||
}
|
}
|
||||||
read_buf[recvd] = '\0';
|
read_buf->val[recvd] = '\0';
|
||||||
|
read_buf->len = recvd;
|
||||||
RETURN_STRINGL(read_buf, recvd, 0);
|
RETURN_STR(read_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
efree(read_buf);
|
STR_FREE(read_buf);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -414,7 +419,7 @@ PHP_FUNCTION(stream_get_contents)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zsrc);
|
php_stream_from_zval(stream, zsrc);
|
||||||
|
|
||||||
if (desiredpos >= 0) {
|
if (desiredpos >= 0) {
|
||||||
int seek_res = 0;
|
int seek_res = 0;
|
||||||
|
@ -439,7 +444,8 @@ PHP_FUNCTION(stream_get_contents)
|
||||||
len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
|
len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
|
||||||
|
|
||||||
if (contents) {
|
if (contents) {
|
||||||
RETVAL_STRINGL(contents, len, 0);
|
//??? RETVAL_STRINGL(contents, len, 0);
|
||||||
|
RETVAL_STRINGL(contents, len);
|
||||||
} else {
|
} else {
|
||||||
RETVAL_EMPTY_STRING();
|
RETVAL_EMPTY_STRING();
|
||||||
}
|
}
|
||||||
|
@ -460,8 +466,8 @@ PHP_FUNCTION(stream_copy_to_stream)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(src, &zsrc);
|
php_stream_from_zval(src, zsrc);
|
||||||
php_stream_from_zval(dest, &zdest);
|
php_stream_from_zval(dest, zdest);
|
||||||
|
|
||||||
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
|
if (pos > 0 && php_stream_seek(src, pos, SEEK_SET) < 0) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
|
||||||
|
@ -483,20 +489,16 @@ PHP_FUNCTION(stream_get_meta_data)
|
||||||
{
|
{
|
||||||
zval *arg1;
|
zval *arg1;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
zval *newval;
|
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
php_stream_from_zval(stream, &arg1);
|
php_stream_from_zval(stream, arg1);
|
||||||
|
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
|
|
||||||
if (stream->wrapperdata) {
|
if (Z_TYPE(stream->wrapperdata) != IS_NULL) {
|
||||||
MAKE_STD_ZVAL(newval);
|
add_assoc_zval(return_value, "wrapper_data", &stream->wrapperdata);
|
||||||
MAKE_COPY_ZVAL(&stream->wrapperdata, newval);
|
|
||||||
|
|
||||||
add_assoc_zval(return_value, "wrapper_data", newval);
|
|
||||||
}
|
}
|
||||||
if (stream->wrapper) {
|
if (stream->wrapper) {
|
||||||
add_assoc_string(return_value, "wrapper_type", (char *)stream->wrapper->wops->label, 1);
|
add_assoc_string(return_value, "wrapper_type", (char *)stream->wrapper->wops->label, 1);
|
||||||
|
@ -541,8 +543,7 @@ PHP_FUNCTION(stream_get_meta_data)
|
||||||
PHP_FUNCTION(stream_get_transports)
|
PHP_FUNCTION(stream_get_transports)
|
||||||
{
|
{
|
||||||
HashTable *stream_xport_hash;
|
HashTable *stream_xport_hash;
|
||||||
char *stream_xport;
|
zend_string *stream_xport;
|
||||||
uint stream_xport_len;
|
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
|
|
||||||
if (zend_parse_parameters_none() == FAILURE) {
|
if (zend_parse_parameters_none() == FAILURE) {
|
||||||
|
@ -554,9 +555,9 @@ PHP_FUNCTION(stream_get_transports)
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
|
zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
|
||||||
while (zend_hash_get_current_key_ex(stream_xport_hash,
|
while (zend_hash_get_current_key_ex(stream_xport_hash,
|
||||||
&stream_xport, &stream_xport_len,
|
&stream_xport, &num_key, 0, &pos) == HASH_KEY_IS_STRING) {
|
||||||
&num_key, 0, &pos) == HASH_KEY_IS_STRING) {
|
//???
|
||||||
add_next_index_stringl(return_value, stream_xport, stream_xport_len - 1, 1);
|
add_next_index_stringl(return_value, stream_xport->val, stream_xport->len, 1);
|
||||||
zend_hash_move_forward_ex(stream_xport_hash, &pos);
|
zend_hash_move_forward_ex(stream_xport_hash, &pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -570,9 +571,8 @@ PHP_FUNCTION(stream_get_transports)
|
||||||
PHP_FUNCTION(stream_get_wrappers)
|
PHP_FUNCTION(stream_get_wrappers)
|
||||||
{
|
{
|
||||||
HashTable *url_stream_wrappers_hash;
|
HashTable *url_stream_wrappers_hash;
|
||||||
char *stream_protocol;
|
zend_string *stream_protocol;
|
||||||
int key_flags;
|
int key_flags;
|
||||||
uint stream_protocol_len = 0;
|
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
|
|
||||||
if (zend_parse_parameters_none() == FAILURE) {
|
if (zend_parse_parameters_none() == FAILURE) {
|
||||||
|
@ -583,10 +583,11 @@ PHP_FUNCTION(stream_get_wrappers)
|
||||||
HashPosition pos;
|
HashPosition pos;
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
|
for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
|
||||||
(key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT;
|
(key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT;
|
||||||
zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
|
zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
|
||||||
if (key_flags == HASH_KEY_IS_STRING) {
|
if (key_flags == HASH_KEY_IS_STRING) {
|
||||||
add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1);
|
//???
|
||||||
|
add_next_index_stringl(return_value, stream_protocol->val, stream_protocol->len, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -599,7 +600,7 @@ PHP_FUNCTION(stream_get_wrappers)
|
||||||
/* {{{ stream_select related functions */
|
/* {{{ stream_select related functions */
|
||||||
static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t *max_fd TSRMLS_DC)
|
static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t *max_fd TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **elem;
|
zval *elem;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
|
@ -607,7 +608,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
||||||
zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
|
(elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) != NULL;
|
||||||
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
||||||
|
|
||||||
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
|
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
|
||||||
|
@ -641,24 +642,22 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
|
||||||
|
|
||||||
static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **elem, **dest_elem;
|
zval *elem, *dest_elem, new_array;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
HashTable *new_hash;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
|
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ALLOC_HASHTABLE(new_hash);
|
ZVAL_NEW_ARR(&new_array);
|
||||||
zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
||||||
|
|
||||||
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
||||||
zend_hash_has_more_elements(Z_ARRVAL_P(stream_array)) == SUCCESS;
|
zend_hash_has_more_elements(Z_ARRVAL_P(stream_array)) == SUCCESS;
|
||||||
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
char *key;
|
zend_string *key;
|
||||||
uint key_len;
|
|
||||||
ulong num_ind;
|
ulong num_ind;
|
||||||
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
|
/* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
|
||||||
would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
|
would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
|
||||||
|
@ -667,9 +666,9 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
||||||
|
|
||||||
|
|
||||||
type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
|
type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
|
||||||
&key, &key_len, &num_ind, 0, NULL);
|
&key, &num_ind, 0, NULL);
|
||||||
if (type == HASH_KEY_NON_EXISTENT ||
|
if (type == HASH_KEY_NON_EXISTENT ||
|
||||||
zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) {
|
(elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) == NULL) {
|
||||||
continue; /* should not happen */
|
continue; /* should not happen */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,9 +687,9 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
||||||
|
|
||||||
if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
|
if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
|
||||||
if (type == HASH_KEY_IS_LONG) {
|
if (type == HASH_KEY_IS_LONG) {
|
||||||
zend_hash_index_update(new_hash, num_ind, (void *)elem, sizeof(zval *), (void **)&dest_elem);
|
dest_elem = zend_hash_index_update(Z_ARRVAL(new_array), num_ind, elem);
|
||||||
} else { /* HASH_KEY_IS_STRING */
|
} else { /* HASH_KEY_IS_STRING */
|
||||||
zend_hash_update(new_hash, key, key_len, (void *)elem, sizeof(zval *), (void **)&dest_elem);
|
dest_elem = zend_hash_update(Z_ARRVAL(new_array), key, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest_elem) {
|
if (dest_elem) {
|
||||||
|
@ -704,29 +703,28 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
|
||||||
|
|
||||||
/* destroy old array and add new one */
|
/* destroy old array and add new one */
|
||||||
zend_hash_destroy(Z_ARRVAL_P(stream_array));
|
zend_hash_destroy(Z_ARRVAL_P(stream_array));
|
||||||
efree(Z_ARRVAL_P(stream_array));
|
efree(Z_ARR_P(stream_array));
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset(new_hash);
|
zend_hash_internal_pointer_reset(Z_ARRVAL(new_array));
|
||||||
Z_ARRVAL_P(stream_array) = new_hash;
|
Z_ARR_P(stream_array) = Z_ARR(new_array);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **elem, **dest_elem;
|
zval *elem, *dest_elem, new_array;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
HashTable *new_hash;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
|
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ALLOC_HASHTABLE(new_hash);
|
ZVAL_NEW_ARR(&new_array);
|
||||||
zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
|
||||||
|
|
||||||
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
|
||||||
zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
|
(elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) != NULL;
|
||||||
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
|
||||||
|
|
||||||
php_stream_from_zval_no_verify(stream, elem);
|
php_stream_from_zval_no_verify(stream, elem);
|
||||||
|
@ -740,7 +738,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
||||||
* This branch of code also allows blocking streams with buffered data to
|
* This branch of code also allows blocking streams with buffered data to
|
||||||
* operate correctly in stream_select.
|
* operate correctly in stream_select.
|
||||||
* */
|
* */
|
||||||
zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem);
|
dest_elem = zend_hash_next_index_insert(Z_ARRVAL(new_array), elem);
|
||||||
if (dest_elem) {
|
if (dest_elem) {
|
||||||
zval_add_ref(dest_elem);
|
zval_add_ref(dest_elem);
|
||||||
}
|
}
|
||||||
|
@ -752,13 +750,13 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
/* destroy old array and add new one */
|
/* destroy old array and add new one */
|
||||||
zend_hash_destroy(Z_ARRVAL_P(stream_array));
|
zend_hash_destroy(Z_ARRVAL_P(stream_array));
|
||||||
efree(Z_ARRVAL_P(stream_array));
|
efree(Z_ARR_P(stream_array));
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset(new_hash);
|
zend_hash_internal_pointer_reset(Z_ARRVAL(new_array));
|
||||||
Z_ARRVAL_P(stream_array) = new_hash;
|
Z_ARR_P(stream_array) = Z_ARR(new_array);
|
||||||
} else {
|
} else {
|
||||||
zend_hash_destroy(new_hash);
|
zend_hash_destroy(Z_ARRVAL(new_array));
|
||||||
FREE_HASHTABLE(new_hash);
|
efree(Z_ARR(new_array));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -769,7 +767,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array TSRMLS_DC)
|
||||||
Runs the select() system call on the sets of streams with a timeout specified by tv_sec and tv_usec */
|
Runs the select() system call on the sets of streams with a timeout specified by tv_sec and tv_usec */
|
||||||
PHP_FUNCTION(stream_select)
|
PHP_FUNCTION(stream_select)
|
||||||
{
|
{
|
||||||
zval *r_array, *w_array, *e_array, **sec = NULL;
|
zval *r_array, *w_array, *e_array, *sec = NULL;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timeval *tv_p = NULL;
|
struct timeval *tv_p = NULL;
|
||||||
fd_set rfds, wfds, efds;
|
fd_set rfds, wfds, efds;
|
||||||
|
@ -778,7 +776,7 @@ PHP_FUNCTION(stream_select)
|
||||||
long usec = 0;
|
long usec = 0;
|
||||||
int set_count, max_set_count = 0;
|
int set_count, max_set_count = 0;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!Z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
|
@ -817,7 +815,7 @@ PHP_FUNCTION(stream_select)
|
||||||
if (sec != NULL) {
|
if (sec != NULL) {
|
||||||
convert_to_long_ex(sec);
|
convert_to_long_ex(sec);
|
||||||
|
|
||||||
if (Z_LVAL_PP(sec) < 0) {
|
if (Z_LVAL_P(sec) < 0) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The seconds parameter must be greater than 0");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
} else if (usec < 0) {
|
} else if (usec < 0) {
|
||||||
|
@ -827,10 +825,10 @@ PHP_FUNCTION(stream_select)
|
||||||
|
|
||||||
/* Solaris + BSD do not like microsecond values which are >= 1 sec */
|
/* Solaris + BSD do not like microsecond values which are >= 1 sec */
|
||||||
if (usec > 999999) {
|
if (usec > 999999) {
|
||||||
tv.tv_sec = Z_LVAL_PP(sec) + (usec / 1000000);
|
tv.tv_sec = Z_LVAL_P(sec) + (usec / 1000000);
|
||||||
tv.tv_usec = usec % 1000000;
|
tv.tv_usec = usec % 1000000;
|
||||||
} else {
|
} else {
|
||||||
tv.tv_sec = Z_LVAL_PP(sec);
|
tv.tv_sec = Z_LVAL_P(sec);
|
||||||
tv.tv_usec = usec;
|
tv.tv_usec = usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,45 +873,34 @@ static void user_space_stream_notifier(php_stream_context *context, int notifyco
|
||||||
char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC)
|
char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *callback = (zval*)context->notifier->ptr;
|
zval *callback = (zval*)context->notifier->ptr;
|
||||||
zval *retval = NULL;
|
zval retval;
|
||||||
zval zvs[6];
|
zval zvs[6];
|
||||||
zval *ps[6];
|
|
||||||
zval **ptps[6];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
ZVAL_LONG(&zvs[0], notifycode);
|
||||||
INIT_ZVAL(zvs[i]);
|
ZVAL_LONG(&zvs[1], severity);
|
||||||
ps[i] = &zvs[i];
|
|
||||||
ptps[i] = &ps[i];
|
|
||||||
MAKE_STD_ZVAL(ps[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZVAL_LONG(ps[0], notifycode);
|
|
||||||
ZVAL_LONG(ps[1], severity);
|
|
||||||
if (xmsg) {
|
if (xmsg) {
|
||||||
ZVAL_STRING(ps[2], xmsg, 1);
|
ZVAL_STRING(&zvs[2], xmsg);
|
||||||
} else {
|
} else {
|
||||||
ZVAL_NULL(ps[2]);
|
ZVAL_NULL(&zvs[2]);
|
||||||
}
|
}
|
||||||
ZVAL_LONG(ps[3], xcode);
|
ZVAL_LONG(&zvs[3], xcode);
|
||||||
ZVAL_LONG(ps[4], bytes_sofar);
|
ZVAL_LONG(&zvs[4], bytes_sofar);
|
||||||
ZVAL_LONG(ps[5], bytes_max);
|
ZVAL_LONG(&zvs[5], bytes_max);
|
||||||
|
|
||||||
if (FAILURE == call_user_function_ex(EG(function_table), NULL, callback, &retval, 6, ptps, 0, NULL TSRMLS_CC)) {
|
if (FAILURE == call_user_function_ex(EG(function_table), NULL, callback, &retval, 6, zvs, 0, NULL TSRMLS_CC)) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call user notifier");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call user notifier");
|
||||||
}
|
}
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
zval_ptr_dtor(&ps[i]);
|
zval_ptr_dtor(&zvs[i]);
|
||||||
}
|
|
||||||
if (retval) {
|
|
||||||
zval_ptr_dtor(&retval);
|
|
||||||
}
|
}
|
||||||
|
zval_ptr_dtor(&retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
|
static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
|
||||||
{
|
{
|
||||||
if (notifier && notifier->ptr) {
|
if (notifier && notifier->ptr) {
|
||||||
zval_ptr_dtor((zval **)&(notifier->ptr));
|
zval_ptr_dtor((zval*)(notifier->ptr));
|
||||||
notifier->ptr = NULL;
|
notifier->ptr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -921,24 +908,23 @@ static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
|
||||||
static int parse_context_options(php_stream_context *context, zval *options TSRMLS_DC)
|
static int parse_context_options(php_stream_context *context, zval *options TSRMLS_DC)
|
||||||
{
|
{
|
||||||
HashPosition pos, opos;
|
HashPosition pos, opos;
|
||||||
zval **wval, **oval;
|
zval *wval, *oval;
|
||||||
char *wkey, *okey;
|
zend_string *wkey, *okey;
|
||||||
uint wkey_len, okey_len;
|
|
||||||
int ret = SUCCESS;
|
int ret = SUCCESS;
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(options), &pos);
|
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(options), &pos);
|
||||||
while (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_P(options), (void**)&wval, &pos)) {
|
while (NULL != (wval = zend_hash_get_current_data_ex(Z_ARRVAL_P(options), &pos))) {
|
||||||
if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(options), &wkey, &wkey_len, &num_key, 0, &pos)
|
if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(options), &wkey, &num_key, 0, &pos)
|
||||||
&& Z_TYPE_PP(wval) == IS_ARRAY) {
|
&& Z_TYPE_P(wval) == IS_ARRAY) {
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(wval), &opos);
|
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(wval), &opos);
|
||||||
while (SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(wval), (void**)&oval, &opos)) {
|
while (NULL != (oval = zend_hash_get_current_data_ex(Z_ARRVAL_P(wval), &opos))) {
|
||||||
|
|
||||||
if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_PP(wval), &okey, &okey_len, &num_key, 0, &opos)) {
|
if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(wval), &okey, &num_key, 0, &opos)) {
|
||||||
php_stream_context_set_option(context, wkey, okey, *oval);
|
php_stream_context_set_option(context, wkey->val, okey->val, oval);
|
||||||
}
|
}
|
||||||
zend_hash_move_forward_ex(Z_ARRVAL_PP(wval), &opos);
|
zend_hash_move_forward_ex(Z_ARRVAL_P(wval), &opos);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -953,9 +939,9 @@ static int parse_context_options(php_stream_context *context, zval *options TSRM
|
||||||
static int parse_context_params(php_stream_context *context, zval *params TSRMLS_DC)
|
static int parse_context_params(php_stream_context *context, zval *params TSRMLS_DC)
|
||||||
{
|
{
|
||||||
int ret = SUCCESS;
|
int ret = SUCCESS;
|
||||||
zval **tmp;
|
zval *tmp;
|
||||||
|
|
||||||
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp)) {
|
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "notification", sizeof("notification")-1))) {
|
||||||
|
|
||||||
if (context->notifier) {
|
if (context->notifier) {
|
||||||
php_stream_notification_free(context->notifier);
|
php_stream_notification_free(context->notifier);
|
||||||
|
@ -964,13 +950,13 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
|
||||||
|
|
||||||
context->notifier = php_stream_notification_alloc();
|
context->notifier = php_stream_notification_alloc();
|
||||||
context->notifier->func = user_space_stream_notifier;
|
context->notifier->func = user_space_stream_notifier;
|
||||||
context->notifier->ptr = *tmp;
|
context->notifier->ptr = tmp;
|
||||||
Z_ADDREF_P(*tmp);
|
Z_ADDREF_P(tmp);
|
||||||
context->notifier->dtor = user_space_stream_notifier_dtor;
|
context->notifier->dtor = user_space_stream_notifier_dtor;
|
||||||
}
|
}
|
||||||
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) {
|
if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(params), "options", sizeof("options")-1))) {
|
||||||
if (Z_TYPE_PP(tmp) == IS_ARRAY) {
|
if (Z_TYPE_P(tmp) == IS_ARRAY) {
|
||||||
parse_context_options(context, *tmp TSRMLS_CC);
|
parse_context_options(context, tmp TSRMLS_CC);
|
||||||
} else {
|
} else {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter");
|
||||||
}
|
}
|
||||||
|
@ -986,11 +972,11 @@ static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC)
|
||||||
{
|
{
|
||||||
php_stream_context *context = NULL;
|
php_stream_context *context = NULL;
|
||||||
|
|
||||||
context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context(TSRMLS_C));
|
context = zend_fetch_resource(contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context(TSRMLS_C));
|
||||||
if (context == NULL) {
|
if (context == NULL) {
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
|
|
||||||
stream = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
|
stream = zend_fetch_resource(contextresource TSRMLS_CC, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream);
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
context = stream->context;
|
context = stream->context;
|
||||||
|
@ -1024,7 +1010,7 @@ PHP_FUNCTION(stream_context_get_options)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_ZVAL(context->options, 1, 0);
|
RETURN_ZVAL(&context->options, 1, 0);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1089,7 +1075,7 @@ PHP_FUNCTION(stream_context_set_params)
|
||||||
Get parameters of a file context */
|
Get parameters of a file context */
|
||||||
PHP_FUNCTION(stream_context_get_params)
|
PHP_FUNCTION(stream_context_get_params)
|
||||||
{
|
{
|
||||||
zval *zcontext, *options;
|
zval *zcontext, options;
|
||||||
php_stream_context *context;
|
php_stream_context *context;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zcontext) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zcontext) == FAILURE) {
|
||||||
|
@ -1107,9 +1093,8 @@ PHP_FUNCTION(stream_context_get_params)
|
||||||
add_assoc_zval_ex(return_value, ZEND_STRS("notification"), context->notifier->ptr);
|
add_assoc_zval_ex(return_value, ZEND_STRS("notification"), context->notifier->ptr);
|
||||||
Z_ADDREF_P(context->notifier->ptr);
|
Z_ADDREF_P(context->notifier->ptr);
|
||||||
}
|
}
|
||||||
ALLOC_INIT_ZVAL(options);
|
ZVAL_ZVAL(&options, &context->options, 1, 0);
|
||||||
ZVAL_ZVAL(options, context->options, 1, 0);
|
add_assoc_zval_ex(return_value, ZEND_STRS("options"), &options);
|
||||||
add_assoc_zval_ex(return_value, ZEND_STRS("options"), options);
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1180,7 +1165,7 @@ PHP_FUNCTION(stream_context_create)
|
||||||
parse_context_params(context, params TSRMLS_CC);
|
parse_context_params(context, params TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_RESOURCE(context->rsrc_id);
|
RETURN_RES(context->res);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -1201,7 +1186,7 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if ((read_write & PHP_STREAM_FILTER_ALL) == 0) {
|
if ((read_write & PHP_STREAM_FILTER_ALL) == 0) {
|
||||||
/* Chain not specified.
|
/* Chain not specified.
|
||||||
|
@ -1252,7 +1237,8 @@ static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
RETURN_RESOURCE(filter->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter()));
|
filter->res = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter());
|
||||||
|
RETURN_RES(filter->res);
|
||||||
} else {
|
} else {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1286,7 +1272,7 @@ PHP_FUNCTION(stream_filter_remove)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter = zend_fetch_resource(&zfilter TSRMLS_CC, -1, NULL, NULL, 1, php_file_le_stream_filter());
|
filter = zend_fetch_resource(zfilter TSRMLS_CC, -1, NULL, NULL, 1, php_file_le_stream_filter());
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid resource given, not a stream filter");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid resource given, not a stream filter");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
@ -1297,7 +1283,7 @@ PHP_FUNCTION(stream_filter_remove)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zend_list_delete(Z_LVAL_P(zfilter)) == FAILURE) {
|
if (zend_list_delete(Z_RES_P(zfilter)) == FAILURE) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not invalidate filter, not removing");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not invalidate filter, not removing");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1331,10 +1317,11 @@ PHP_FUNCTION(stream_get_line)
|
||||||
max_length = PHP_SOCK_CHUNK_SIZE;
|
max_length = PHP_SOCK_CHUNK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if ((buf = php_stream_get_record(stream, max_length, &buf_size, str, str_len TSRMLS_CC))) {
|
if ((buf = php_stream_get_record(stream, max_length, &buf_size, str, str_len TSRMLS_CC))) {
|
||||||
RETURN_STRINGL(buf, buf_size, 0);
|
//??? RETURN_STRINGL(buf, buf_size, 0);
|
||||||
|
RETURN_STRINGL(buf, buf_size);
|
||||||
} else {
|
} else {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1355,7 +1342,7 @@ PHP_FUNCTION(stream_set_blocking)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &arg1);
|
php_stream_from_zval(stream, arg1);
|
||||||
|
|
||||||
block = arg2;
|
block = arg2;
|
||||||
|
|
||||||
|
@ -1383,7 +1370,7 @@ PHP_FUNCTION(stream_set_timeout)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &socket);
|
php_stream_from_zval(stream, socket);
|
||||||
|
|
||||||
t.tv_sec = seconds;
|
t.tv_sec = seconds;
|
||||||
|
|
||||||
|
@ -1417,7 +1404,7 @@ PHP_FUNCTION(stream_set_write_buffer)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &arg1);
|
php_stream_from_zval(stream, arg1);
|
||||||
|
|
||||||
buff = arg2;
|
buff = arg2;
|
||||||
|
|
||||||
|
@ -1458,7 +1445,7 @@ PHP_FUNCTION(stream_set_chunk_size)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
|
ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
|
||||||
|
|
||||||
|
@ -1480,7 +1467,7 @@ PHP_FUNCTION(stream_set_read_buffer)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &arg1);
|
php_stream_from_zval(stream, arg1);
|
||||||
|
|
||||||
buff = arg2;
|
buff = arg2;
|
||||||
|
|
||||||
|
@ -1509,11 +1496,11 @@ PHP_FUNCTION(stream_socket_enable_crypto)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() >= 3) {
|
if (ZEND_NUM_ARGS() >= 3) {
|
||||||
if (zsessstream) {
|
if (zsessstream) {
|
||||||
php_stream_from_zval(sessstream, &zsessstream);
|
php_stream_from_zval(sessstream, zsessstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream TSRMLS_CC) < 0) {
|
if (php_stream_xport_crypto_setup(stream, cryptokind, sessstream TSRMLS_CC) < 0) {
|
||||||
|
@ -1552,7 +1539,8 @@ PHP_FUNCTION(stream_resolve_include_path)
|
||||||
resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC);
|
resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC);
|
||||||
|
|
||||||
if (resolved_path) {
|
if (resolved_path) {
|
||||||
RETURN_STRING(resolved_path, 0);
|
//??? RETURN_STRING(resolved_path, 0);
|
||||||
|
RETURN_STRING(resolved_path);
|
||||||
}
|
}
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1562,15 +1550,15 @@ PHP_FUNCTION(stream_resolve_include_path)
|
||||||
*/
|
*/
|
||||||
PHP_FUNCTION(stream_is_local)
|
PHP_FUNCTION(stream_is_local)
|
||||||
{
|
{
|
||||||
zval **zstream;
|
zval *zstream;
|
||||||
php_stream *stream = NULL;
|
php_stream *stream = NULL;
|
||||||
php_stream_wrapper *wrapper = NULL;
|
php_stream_wrapper *wrapper = NULL;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &zstream) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zstream) == FAILURE) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_TYPE_PP(zstream) == IS_RESOURCE) {
|
if (Z_TYPE_P(zstream) == IS_RESOURCE) {
|
||||||
php_stream_from_zval(stream, zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
@ -1579,7 +1567,7 @@ PHP_FUNCTION(stream_is_local)
|
||||||
} else {
|
} else {
|
||||||
convert_to_string_ex(zstream);
|
convert_to_string_ex(zstream);
|
||||||
|
|
||||||
wrapper = php_stream_locate_url_wrapper(Z_STRVAL_PP(zstream), NULL, 0 TSRMLS_CC);
|
wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(zstream), NULL, 0 TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wrapper) {
|
if (!wrapper) {
|
||||||
|
@ -1601,7 +1589,7 @@ PHP_FUNCTION(stream_supports_lock)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zsrc);
|
php_stream_from_zval(stream, zsrc);
|
||||||
|
|
||||||
if (!php_stream_supports_lock(stream)) {
|
if (!php_stream_supports_lock(stream)) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
@ -1633,7 +1621,7 @@ PHP_FUNCTION(stream_socket_shutdown)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
RETURN_BOOL(php_stream_xport_shutdown(stream, (stream_shutdown_t)how TSRMLS_CC) == 0);
|
RETURN_BOOL(php_stream_xport_shutdown(stream, (stream_shutdown_t)how TSRMLS_CC) == 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
struct php_user_filter_data {
|
struct php_user_filter_data {
|
||||||
zend_class_entry *ce;
|
zend_class_entry *ce;
|
||||||
/* variable length; this *must* be last in the structure */
|
/* variable length; this *must* be last in the structure */
|
||||||
char classname[1];
|
zend_string *classname;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* to provide context for calling into the next filter from user-space */
|
/* to provide context for calling into the next filter from user-space */
|
||||||
|
@ -78,7 +78,7 @@ static zend_class_entry user_filter_class_entry;
|
||||||
|
|
||||||
static ZEND_RSRC_DTOR_FUNC(php_bucket_dtor)
|
static ZEND_RSRC_DTOR_FUNC(php_bucket_dtor)
|
||||||
{
|
{
|
||||||
php_stream_bucket *bucket = (php_stream_bucket *)rsrc->ptr;
|
php_stream_bucket *bucket = (php_stream_bucket *)res->ptr;
|
||||||
if (bucket) {
|
if (bucket) {
|
||||||
php_stream_bucket_delref(bucket TSRMLS_CC);
|
php_stream_bucket_delref(bucket TSRMLS_CC);
|
||||||
bucket = NULL;
|
bucket = NULL;
|
||||||
|
@ -139,27 +139,27 @@ static void userfilter_dtor(php_stream_filter *thisfilter TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *obj = (zval*)thisfilter->abstract;
|
zval *obj = (zval*)thisfilter->abstract;
|
||||||
zval func_name;
|
zval func_name;
|
||||||
zval *retval = NULL;
|
zval retval;
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
/* If there's no object associated then there's nothing to dispose of */
|
/* If there's no object associated then there's nothing to dispose of */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1, 0);
|
//??? ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1, 0);
|
||||||
|
ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1);
|
||||||
|
|
||||||
call_user_function_ex(NULL,
|
call_user_function_ex(NULL,
|
||||||
&obj,
|
obj,
|
||||||
&func_name,
|
&func_name,
|
||||||
&retval,
|
&retval,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
0, NULL TSRMLS_CC);
|
0, NULL TSRMLS_CC);
|
||||||
|
|
||||||
if (retval)
|
zval_ptr_dtor(&retval);
|
||||||
zval_ptr_dtor(&retval);
|
|
||||||
|
|
||||||
/* kill the object */
|
/* kill the object */
|
||||||
zval_ptr_dtor(&obj);
|
zval_ptr_dtor(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_filter_status_t userfilter_filter(
|
php_stream_filter_status_t userfilter_filter(
|
||||||
|
@ -174,65 +174,54 @@ php_stream_filter_status_t userfilter_filter(
|
||||||
int ret = PSFS_ERR_FATAL;
|
int ret = PSFS_ERR_FATAL;
|
||||||
zval *obj = (zval*)thisfilter->abstract;
|
zval *obj = (zval*)thisfilter->abstract;
|
||||||
zval func_name;
|
zval func_name;
|
||||||
zval *retval = NULL;
|
zval retval;
|
||||||
zval **args[4];
|
zval args[4];
|
||||||
zval *zclosing, *zconsumed, *zin, *zout, *zstream;
|
|
||||||
zval zpropname;
|
zval zpropname;
|
||||||
int call_result;
|
int call_result;
|
||||||
|
|
||||||
if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), "stream", sizeof("stream"), (void**)&zstream)) {
|
if (!zend_hash_str_exists(Z_OBJPROP_P(obj), "stream", sizeof("stream")-1)) {
|
||||||
|
zval tmp;
|
||||||
|
|
||||||
/* Give the userfilter class a hook back to the stream */
|
/* Give the userfilter class a hook back to the stream */
|
||||||
ALLOC_INIT_ZVAL(zstream);
|
php_stream_to_zval(stream, &tmp);
|
||||||
php_stream_to_zval(stream, zstream);
|
zval_copy_ctor(&tmp);
|
||||||
zval_copy_ctor(zstream);
|
add_property_zval(obj, "stream", &tmp);
|
||||||
add_property_zval(obj, "stream", zstream);
|
|
||||||
/* add_property_zval increments the refcount which is unwanted here */
|
/* add_property_zval increments the refcount which is unwanted here */
|
||||||
zval_ptr_dtor(&zstream);
|
zval_ptr_dtor(&tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1, 0);
|
//??? ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1, 0);
|
||||||
|
ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1);
|
||||||
|
|
||||||
/* Setup calling arguments */
|
/* Setup calling arguments */
|
||||||
ALLOC_INIT_ZVAL(zin);
|
ZEND_REGISTER_RESOURCE(&args[0], buckets_in, le_bucket_brigade);
|
||||||
ZEND_REGISTER_RESOURCE(zin, buckets_in, le_bucket_brigade);
|
|
||||||
args[0] = &zin;
|
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(zout);
|
ZEND_REGISTER_RESOURCE(&args[1], buckets_out, le_bucket_brigade);
|
||||||
ZEND_REGISTER_RESOURCE(zout, buckets_out, le_bucket_brigade);
|
|
||||||
args[1] = &zout;
|
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(zconsumed);
|
|
||||||
if (bytes_consumed) {
|
if (bytes_consumed) {
|
||||||
ZVAL_LONG(zconsumed, *bytes_consumed);
|
ZVAL_LONG(&args[2], *bytes_consumed);
|
||||||
} else {
|
} else {
|
||||||
ZVAL_NULL(zconsumed);
|
ZVAL_NULL(&args[2]);
|
||||||
}
|
}
|
||||||
args[2] = &zconsumed;
|
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(zclosing);
|
ZVAL_BOOL(&args[3], flags & PSFS_FLAG_FLUSH_CLOSE);
|
||||||
ZVAL_BOOL(zclosing, flags & PSFS_FLAG_FLUSH_CLOSE);
|
|
||||||
args[3] = &zclosing;
|
|
||||||
|
|
||||||
call_result = call_user_function_ex(NULL,
|
call_result = call_user_function_ex(NULL,
|
||||||
&obj,
|
obj,
|
||||||
&func_name,
|
&func_name,
|
||||||
&retval,
|
&retval,
|
||||||
4, args,
|
4, args,
|
||||||
0, NULL TSRMLS_CC);
|
0, NULL TSRMLS_CC);
|
||||||
|
|
||||||
if (call_result == SUCCESS && retval != NULL) {
|
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
|
||||||
convert_to_long(retval);
|
convert_to_long(&retval);
|
||||||
ret = Z_LVAL_P(retval);
|
ret = Z_LVAL(retval);
|
||||||
} else if (call_result == FAILURE) {
|
} else if (call_result == FAILURE) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call filter function");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to call filter function");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes_consumed) {
|
if (bytes_consumed) {
|
||||||
*bytes_consumed = Z_LVAL_P(zconsumed);
|
*bytes_consumed = Z_LVAL_P(&args[2]);
|
||||||
}
|
|
||||||
|
|
||||||
if (retval) {
|
|
||||||
zval_ptr_dtor(&retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buckets_in->head) {
|
if (buckets_in->head) {
|
||||||
|
@ -257,14 +246,14 @@ php_stream_filter_status_t userfilter_filter(
|
||||||
/* filter resources are cleaned up by the stream destructor,
|
/* filter resources are cleaned up by the stream destructor,
|
||||||
* keeping a reference to the stream resource here would prevent it
|
* keeping a reference to the stream resource here would prevent it
|
||||||
* from being destroyed properly */
|
* from being destroyed properly */
|
||||||
INIT_ZVAL(zpropname);
|
//??? ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1, 0);
|
||||||
ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1, 0);
|
ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1);
|
||||||
Z_OBJ_HANDLER_P(obj, unset_property)(obj, &zpropname, 0 TSRMLS_CC);
|
Z_OBJ_HANDLER_P(obj, unset_property)(obj, &zpropname, 0 TSRMLS_CC);
|
||||||
|
|
||||||
zval_ptr_dtor(&zclosing);
|
zval_ptr_dtor(&args[3]);
|
||||||
zval_ptr_dtor(&zconsumed);
|
zval_ptr_dtor(&args[2]);
|
||||||
zval_ptr_dtor(&zout);
|
zval_ptr_dtor(&args[1]);
|
||||||
zval_ptr_dtor(&zin);
|
zval_ptr_dtor(&args[0]);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -280,9 +269,9 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
{
|
{
|
||||||
struct php_user_filter_data *fdat = NULL;
|
struct php_user_filter_data *fdat = NULL;
|
||||||
php_stream_filter *filter;
|
php_stream_filter *filter;
|
||||||
zval *obj, *zfilter;
|
zval obj, zfilter;
|
||||||
zval func_name;
|
zval func_name;
|
||||||
zval *retval = NULL;
|
zval retval;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* some sanity checks */
|
/* some sanity checks */
|
||||||
|
@ -295,7 +284,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
len = strlen(filtername);
|
len = strlen(filtername);
|
||||||
|
|
||||||
/* determine the classname/class entry */
|
/* determine the classname/class entry */
|
||||||
if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, len + 1, (void**)&fdat)) {
|
if (NULL == (fdat = zend_hash_str_find_ptr(BG(user_filter_map), (char*)filtername, len))) {
|
||||||
char *period;
|
char *period;
|
||||||
|
|
||||||
/* Userspace Filters using ambiguous wildcards could cause problems.
|
/* Userspace Filters using ambiguous wildcards could cause problems.
|
||||||
|
@ -312,7 +301,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
while (period) {
|
while (period) {
|
||||||
*period = '\0';
|
*period = '\0';
|
||||||
strncat(wildcard, ".*", 2);
|
strncat(wildcard, ".*", 2);
|
||||||
if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard) + 1, (void**)&fdat)) {
|
if (NULL != (fdat = zend_hash_str_find_ptr(BG(user_filter_map), wildcard, strlen(wildcard)))) {
|
||||||
period = NULL;
|
period = NULL;
|
||||||
} else {
|
} else {
|
||||||
*period = '\0';
|
*period = '\0';
|
||||||
|
@ -330,15 +319,12 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
|
|
||||||
/* bind the classname to the actual class */
|
/* bind the classname to the actual class */
|
||||||
if (fdat->ce == NULL) {
|
if (fdat->ce == NULL) {
|
||||||
if (FAILURE == zend_lookup_class(fdat->classname, strlen(fdat->classname),
|
if (NULL == (fdat->ce = zend_lookup_class(fdat->classname TSRMLS_CC))) {
|
||||||
(zend_class_entry ***)&fdat->ce TSRMLS_CC)) {
|
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,
|
php_error_docref(NULL TSRMLS_CC, E_WARNING,
|
||||||
"user-filter \"%s\" requires class \"%s\", but that class is not defined",
|
"user-filter \"%s\" requires class \"%s\", but that class is not defined",
|
||||||
filtername, fdat->classname);
|
filtername, fdat->classname->val);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fdat->ce = *(zend_class_entry**)fdat->ce;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filter = php_stream_filter_alloc(&userfilter_ops, NULL, 0);
|
filter = php_stream_filter_alloc(&userfilter_ops, NULL, 0);
|
||||||
|
@ -347,23 +333,22 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the object */
|
/* create the object */
|
||||||
ALLOC_ZVAL(obj);
|
object_init_ex(&obj, fdat->ce);
|
||||||
object_init_ex(obj, fdat->ce);
|
//??? Z_SET_ISREF_P(obj);
|
||||||
Z_SET_REFCOUNT_P(obj, 1);
|
|
||||||
Z_SET_ISREF_P(obj);
|
|
||||||
|
|
||||||
/* filtername */
|
/* filtername */
|
||||||
add_property_string(obj, "filtername", (char*)filtername, 1);
|
add_property_string(&obj, "filtername", (char*)filtername, 1);
|
||||||
|
|
||||||
/* and the parameters, if any */
|
/* and the parameters, if any */
|
||||||
if (filterparams) {
|
if (filterparams) {
|
||||||
add_property_zval(obj, "params", filterparams);
|
add_property_zval(&obj, "params", filterparams);
|
||||||
} else {
|
} else {
|
||||||
add_property_null(obj, "params");
|
add_property_null(&obj, "params");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invoke the constructor */
|
/* invoke the constructor */
|
||||||
ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1, 0);
|
//??? ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1, 0);
|
||||||
|
ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1);
|
||||||
|
|
||||||
call_user_function_ex(NULL,
|
call_user_function_ex(NULL,
|
||||||
&obj,
|
&obj,
|
||||||
|
@ -372,8 +357,8 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
0, NULL TSRMLS_CC);
|
0, NULL TSRMLS_CC);
|
||||||
|
|
||||||
if (retval) {
|
if (Z_TYPE(retval) != IS_UNDEF) {
|
||||||
if (Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) {
|
if (Z_TYPE(retval) == IS_BOOL && Z_LVAL(retval) == 0) {
|
||||||
/* User reported filter creation error "return false;" */
|
/* User reported filter creation error "return false;" */
|
||||||
zval_ptr_dtor(&retval);
|
zval_ptr_dtor(&retval);
|
||||||
|
|
||||||
|
@ -391,10 +376,10 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the filter property, this will be used during cleanup */
|
/* set the filter property, this will be used during cleanup */
|
||||||
ALLOC_INIT_ZVAL(zfilter);
|
ZEND_REGISTER_RESOURCE(&zfilter, filter, le_userfilters);
|
||||||
ZEND_REGISTER_RESOURCE(zfilter, filter, le_userfilters);
|
//???
|
||||||
filter->abstract = obj;
|
filter->abstract = &obj;
|
||||||
add_property_zval(obj, "filter", zfilter);
|
add_property_zval(&obj, "filter", &zfilter);
|
||||||
/* add_property_zval increments the refcount which is unwanted here */
|
/* add_property_zval increments the refcount which is unwanted here */
|
||||||
zval_ptr_dtor(&zfilter);
|
zval_ptr_dtor(&zfilter);
|
||||||
|
|
||||||
|
@ -413,7 +398,7 @@ static void filter_item_dtor(struct php_user_filter_data *fdat)
|
||||||
Return a bucket object from the brigade for operating on */
|
Return a bucket object from the brigade for operating on */
|
||||||
PHP_FUNCTION(stream_bucket_make_writeable)
|
PHP_FUNCTION(stream_bucket_make_writeable)
|
||||||
{
|
{
|
||||||
zval *zbrigade, *zbucket;
|
zval *zbrigade, zbucket;
|
||||||
php_stream_bucket_brigade *brigade;
|
php_stream_bucket_brigade *brigade;
|
||||||
php_stream_bucket *bucket;
|
php_stream_bucket *bucket;
|
||||||
|
|
||||||
|
@ -421,15 +406,14 @@ PHP_FUNCTION(stream_bucket_make_writeable)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, &zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
||||||
|
|
||||||
ZVAL_NULL(return_value);
|
ZVAL_NULL(return_value);
|
||||||
|
|
||||||
if (brigade->head && (bucket = php_stream_bucket_make_writeable(brigade->head TSRMLS_CC))) {
|
if (brigade->head && (bucket = php_stream_bucket_make_writeable(brigade->head TSRMLS_CC))) {
|
||||||
ALLOC_INIT_ZVAL(zbucket);
|
ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
|
||||||
ZEND_REGISTER_RESOURCE(zbucket, bucket, le_bucket);
|
|
||||||
object_init(return_value);
|
object_init(return_value);
|
||||||
add_property_zval(return_value, "bucket", zbucket);
|
add_property_zval(return_value, "bucket", &zbucket);
|
||||||
/* add_property_zval increments the refcount which is unwanted here */
|
/* add_property_zval increments the refcount which is unwanted here */
|
||||||
zval_ptr_dtor(&zbucket);
|
zval_ptr_dtor(&zbucket);
|
||||||
add_property_stringl(return_value, "data", bucket->buf, bucket->buflen, 1);
|
add_property_stringl(return_value, "data", bucket->buf, bucket->buflen, 1);
|
||||||
|
@ -442,7 +426,7 @@ PHP_FUNCTION(stream_bucket_make_writeable)
|
||||||
static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
|
static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||||
{
|
{
|
||||||
zval *zbrigade, *zobject;
|
zval *zbrigade, *zobject;
|
||||||
zval **pzbucket, **pzdata;
|
zval *pzbucket, *pzdata;
|
||||||
php_stream_bucket_brigade *brigade;
|
php_stream_bucket_brigade *brigade;
|
||||||
php_stream_bucket *bucket;
|
php_stream_bucket *bucket;
|
||||||
|
|
||||||
|
@ -450,23 +434,23 @@ static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILURE == zend_hash_find(Z_OBJPROP_P(zobject), "bucket", 7, (void**)&pzbucket)) {
|
if (NULL == (pzbucket = zend_hash_str_find(Z_OBJPROP_P(zobject), "bucket", sizeof("bucket")-1))) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Object has no bucket property");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Object has no bucket property");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, &zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
ZEND_FETCH_RESOURCE(brigade, php_stream_bucket_brigade *, zbrigade, -1, PHP_STREAM_BRIGADE_RES_NAME, le_bucket_brigade);
|
||||||
ZEND_FETCH_RESOURCE(bucket, php_stream_bucket *, pzbucket, -1, PHP_STREAM_BUCKET_RES_NAME, le_bucket);
|
ZEND_FETCH_RESOURCE(bucket, php_stream_bucket *, pzbucket, -1, PHP_STREAM_BUCKET_RES_NAME, le_bucket);
|
||||||
|
|
||||||
if (SUCCESS == zend_hash_find(Z_OBJPROP_P(zobject), "data", 5, (void**)&pzdata) && (*pzdata)->type == IS_STRING) {
|
if (NULL != (pzdata = zend_hash_str_find(Z_OBJPROP_P(zobject), "data", sizeof("data")-1)) && Z_TYPE_P(pzdata) == IS_STRING) {
|
||||||
if (!bucket->own_buf) {
|
if (!bucket->own_buf) {
|
||||||
bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC);
|
bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC);
|
||||||
}
|
}
|
||||||
if ((int)bucket->buflen != Z_STRLEN_PP(pzdata)) {
|
if ((int)bucket->buflen != Z_STRLEN_P(pzdata)) {
|
||||||
bucket->buf = perealloc(bucket->buf, Z_STRLEN_PP(pzdata), bucket->is_persistent);
|
bucket->buf = perealloc(bucket->buf, Z_STRLEN_P(pzdata), bucket->is_persistent);
|
||||||
bucket->buflen = Z_STRLEN_PP(pzdata);
|
bucket->buflen = Z_STRLEN_P(pzdata);
|
||||||
}
|
}
|
||||||
memcpy(bucket->buf, Z_STRVAL_PP(pzdata), bucket->buflen);
|
memcpy(bucket->buf, Z_STRVAL_P(pzdata), bucket->buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (append) {
|
if (append) {
|
||||||
|
@ -503,7 +487,7 @@ PHP_FUNCTION(stream_bucket_append)
|
||||||
Create a new bucket for use on the current stream */
|
Create a new bucket for use on the current stream */
|
||||||
PHP_FUNCTION(stream_bucket_new)
|
PHP_FUNCTION(stream_bucket_new)
|
||||||
{
|
{
|
||||||
zval *zstream, *zbucket;
|
zval *zstream, zbucket;
|
||||||
php_stream *stream;
|
php_stream *stream;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
char *pbuffer;
|
char *pbuffer;
|
||||||
|
@ -514,7 +498,7 @@ PHP_FUNCTION(stream_bucket_new)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zstream);
|
php_stream_from_zval(stream, zstream);
|
||||||
|
|
||||||
if (!(pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream)))) {
|
if (!(pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream)))) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
@ -528,10 +512,9 @@ PHP_FUNCTION(stream_bucket_new)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(zbucket);
|
ZEND_REGISTER_RESOURCE(&zbucket, bucket, le_bucket);
|
||||||
ZEND_REGISTER_RESOURCE(zbucket, bucket, le_bucket);
|
|
||||||
object_init(return_value);
|
object_init(return_value);
|
||||||
add_property_zval(return_value, "bucket", zbucket);
|
add_property_zval(return_value, "bucket", &zbucket);
|
||||||
/* add_property_zval increments the refcount which is unwanted here */
|
/* add_property_zval increments the refcount which is unwanted here */
|
||||||
zval_ptr_dtor(&zbucket);
|
zval_ptr_dtor(&zbucket);
|
||||||
add_property_stringl(return_value, "data", bucket->buf, bucket->buflen, 1);
|
add_property_stringl(return_value, "data", bucket->buf, bucket->buflen, 1);
|
||||||
|
@ -543,9 +526,8 @@ PHP_FUNCTION(stream_bucket_new)
|
||||||
Returns a list of registered filters */
|
Returns a list of registered filters */
|
||||||
PHP_FUNCTION(stream_get_filters)
|
PHP_FUNCTION(stream_get_filters)
|
||||||
{
|
{
|
||||||
char *filter_name;
|
zend_string *filter_name;
|
||||||
int key_flags;
|
int key_flags;
|
||||||
uint filter_name_len = 0;
|
|
||||||
HashTable *filters_hash;
|
HashTable *filters_hash;
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
|
|
||||||
|
@ -559,10 +541,11 @@ PHP_FUNCTION(stream_get_filters)
|
||||||
|
|
||||||
if (filters_hash) {
|
if (filters_hash) {
|
||||||
for(zend_hash_internal_pointer_reset(filters_hash);
|
for(zend_hash_internal_pointer_reset(filters_hash);
|
||||||
(key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT;
|
(key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT;
|
||||||
zend_hash_move_forward(filters_hash))
|
zend_hash_move_forward(filters_hash))
|
||||||
if (key_flags == HASH_KEY_IS_STRING) {
|
if (key_flags == HASH_KEY_IS_STRING) {
|
||||||
add_next_index_stringl(return_value, filter_name, filter_name_len - 1, 1);
|
//???
|
||||||
|
add_next_index_stringl(return_value, filter_name->val, filter_name->len, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* It's okay to return an empty array if no filters are registered */
|
/* It's okay to return an empty array if no filters are registered */
|
||||||
|
@ -573,23 +556,21 @@ PHP_FUNCTION(stream_get_filters)
|
||||||
Registers a custom filter handler class */
|
Registers a custom filter handler class */
|
||||||
PHP_FUNCTION(stream_filter_register)
|
PHP_FUNCTION(stream_filter_register)
|
||||||
{
|
{
|
||||||
char *filtername, *classname;
|
zend_string *filtername, *classname;
|
||||||
int filtername_len, classname_len;
|
|
||||||
struct php_user_filter_data *fdat;
|
struct php_user_filter_data *fdat;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &filtername, &filtername_len,
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS", &filtername, &classname) == FAILURE) {
|
||||||
&classname, &classname_len) == FAILURE) {
|
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETVAL_FALSE;
|
RETVAL_FALSE;
|
||||||
|
|
||||||
if (!filtername_len) {
|
if (!filtername->len) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter name cannot be empty");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter name cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!classname_len) {
|
if (!classname->len) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class name cannot be empty");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class name cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -599,16 +580,16 @@ PHP_FUNCTION(stream_filter_register)
|
||||||
zend_hash_init(BG(user_filter_map), 5, NULL, (dtor_func_t) filter_item_dtor, 0);
|
zend_hash_init(BG(user_filter_map), 5, NULL, (dtor_func_t) filter_item_dtor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fdat = ecalloc(1, sizeof(struct php_user_filter_data) + classname_len);
|
fdat = ecalloc(1, sizeof(struct php_user_filter_data));
|
||||||
memcpy(fdat->classname, classname, classname_len);
|
fdat->classname = STR_COPY(classname);
|
||||||
|
|
||||||
if (zend_hash_add(BG(user_filter_map), filtername, filtername_len + 1, (void*)fdat,
|
if (zend_hash_add_ptr(BG(user_filter_map), filtername, fdat) != NULL &&
|
||||||
sizeof(*fdat) + classname_len, NULL) == SUCCESS &&
|
php_stream_filter_register_factory_volatile(filtername->val, &user_filter_factory TSRMLS_CC) == SUCCESS) {
|
||||||
php_stream_filter_register_factory_volatile(filtername, &user_filter_factory TSRMLS_CC) == SUCCESS) {
|
|
||||||
RETVAL_TRUE;
|
RETVAL_TRUE;
|
||||||
|
} else {
|
||||||
|
STR_RELEASE(classname);
|
||||||
|
efree(fdat);
|
||||||
}
|
}
|
||||||
|
|
||||||
efree(fdat);
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,8 @@ PHP_FUNCTION(convert_uuencode)
|
||||||
|
|
||||||
dst_len = php_uuencode(src, src_len, &dst);
|
dst_len = php_uuencode(src, src_len, &dst);
|
||||||
|
|
||||||
RETURN_STRINGL(dst, dst_len, 0);
|
//??? RETURN_STRINGL(dst, dst_len, 0);
|
||||||
|
RETURN_STRINGL(dst, dst_len);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -219,7 +220,8 @@ PHP_FUNCTION(convert_uudecode)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STRINGL(dst, dst_len, 0);
|
//??? RETURN_STRINGL(dst, dst_len, 0);
|
||||||
|
RETURN_STRINGL(dst, dst_len);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -896,9 +896,9 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC) /* {{{ */
|
PHPAPI void php_var_serialize(smart_str *buf, zval *struc, php_serialize_data_t *var_hash TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
php_var_serialize_intern(buf, *struc, *var_hash TSRMLS_CC);
|
php_var_serialize_intern(buf, struc, *var_hash TSRMLS_CC);
|
||||||
smart_str_0(buf);
|
smart_str_0(buf);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -907,11 +907,11 @@ PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t
|
||||||
Returns a string representation of variable (which can later be unserialized) */
|
Returns a string representation of variable (which can later be unserialized) */
|
||||||
PHP_FUNCTION(serialize)
|
PHP_FUNCTION(serialize)
|
||||||
{
|
{
|
||||||
zval **struc;
|
zval *struc;
|
||||||
php_serialize_data_t var_hash;
|
php_serialize_data_t var_hash;
|
||||||
smart_str buf = {0};
|
smart_str buf = {0};
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &struc) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &struc) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,7 +953,7 @@ PHP_FUNCTION(unserialize)
|
||||||
|
|
||||||
p = (const unsigned char*) buf;
|
p = (const unsigned char*) buf;
|
||||||
PHP_VAR_UNSERIALIZE_INIT(var_hash);
|
PHP_VAR_UNSERIALIZE_INIT(var_hash);
|
||||||
if (!php_var_unserialize(&return_value, &p, p + buf_len, &var_hash TSRMLS_CC)) {
|
if (!php_var_unserialize(return_value, &p, p + buf_len, &var_hash TSRMLS_CC)) {
|
||||||
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
|
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
|
||||||
zval_dtor(return_value);
|
zval_dtor(return_value);
|
||||||
if (!EG(exception)) {
|
if (!EG(exception)) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
| PHP Version 5 |
|
| PHP Version 5 |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
| Copyright (c) 1997-2014 The PHP Group |
|
| Copyright (c) 1997-2013 The PHP Group |
|
||||||
+----------------------------------------------------------------------+
|
+----------------------------------------------------------------------+
|
||||||
| This source file is subject to version 3.01 of the PHP license, |
|
| This source file is subject to version 3.01 of the PHP license, |
|
||||||
| that is bundled with this package in the file LICENSE, and is |
|
| that is bundled with this package in the file LICENSE, and is |
|
||||||
|
@ -34,7 +34,7 @@ typedef struct {
|
||||||
void *next;
|
void *next;
|
||||||
} var_entries;
|
} var_entries;
|
||||||
|
|
||||||
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
static inline void var_push(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last;
|
var_entries *var_hash = (*var_hashx)->last;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -55,10 +55,10 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
||||||
(*var_hashx)->last = var_hash;
|
(*var_hashx)->last = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
|
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last_dtor;
|
var_entries *var_hash = (*var_hashx)->last_dtor;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -79,11 +79,11 @@ PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
|
||||||
(*var_hashx)->last_dtor = var_hash;
|
(*var_hashx)->last_dtor = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_ADDREF_PP(rval);
|
Z_ADDREF_P(rval);
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval)
|
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last_dtor;
|
var_entries *var_hash = (*var_hashx)->last_dtor;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -104,10 +104,10 @@ PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rv
|
||||||
(*var_hashx)->last_dtor = var_hash;
|
(*var_hashx)->last_dtor = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval)
|
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
var_entries *var_hash = (*var_hashx)->first;
|
var_entries *var_hash = (*var_hashx)->first;
|
||||||
|
@ -118,7 +118,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **n
|
||||||
while (var_hash) {
|
while (var_hash) {
|
||||||
for (i = 0; i < var_hash->used_slots; i++) {
|
for (i = 0; i < var_hash->used_slots; i++) {
|
||||||
if (var_hash->data[i] == ozval) {
|
if (var_hash->data[i] == ozval) {
|
||||||
var_hash->data[i] = *nzval;
|
var_hash->data[i] = nzval;
|
||||||
/* do not break here */
|
/* do not break here */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,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, long id, zval ***store)
|
static int var_access(php_unserialize_data_t *var_hashx, long id, zval **store)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->first;
|
var_entries *var_hash = (*var_hashx)->first;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -142,7 +142,7 @@ static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store)
|
||||||
|
|
||||||
if (id < 0 || id >= var_hash->used_slots) return !SUCCESS;
|
if (id < 0 || id >= var_hash->used_slots) return !SUCCESS;
|
||||||
|
|
||||||
*store = &var_hash->data[id];
|
*store = var_hash->data[id];
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
|
||||||
|
|
||||||
while (var_hash) {
|
while (var_hash) {
|
||||||
for (i = 0; i < var_hash->used_slots; i++) {
|
for (i = 0; i < var_hash->used_slots; i++) {
|
||||||
zval_ptr_dtor(&var_hash->data[i]);
|
zval_ptr_dtor(var_hash->data[i]);
|
||||||
}
|
}
|
||||||
next = var_hash->next;
|
next = var_hash->next;
|
||||||
efree(var_hash);
|
efree(var_hash);
|
||||||
|
@ -286,62 +286,52 @@ static inline size_t parse_uiv(const unsigned char *p)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNSERIALIZE_PARAMETER zval **rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC
|
#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
|
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC
|
||||||
|
|
||||||
static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
|
static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
|
||||||
{
|
{
|
||||||
while (elements-- > 0) {
|
while (elements-- > 0) {
|
||||||
zval *key, *data, **old_data;
|
zval key, data, *old_data;
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(key);
|
|
||||||
|
|
||||||
if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
|
if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {
|
if (Z_TYPE(key) != IS_LONG && Z_TYPE(key) != IS_STRING) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(data);
|
|
||||||
|
|
||||||
if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
|
if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
zval_dtor(&data);
|
||||||
zval_dtor(data);
|
|
||||||
FREE_ZVAL(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!objprops) {
|
if (!objprops) {
|
||||||
switch (Z_TYPE_P(key)) {
|
switch (Z_TYPE(key)) {
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
if (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {
|
if ((old_data = zend_hash_index_find(ht, Z_LVAL(key))) != NULL) {
|
||||||
var_push_dtor(var_hash, old_data);
|
var_push_dtor(var_hash, old_data);
|
||||||
}
|
}
|
||||||
zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
|
zend_hash_index_update(ht, Z_LVAL(key), &data);
|
||||||
break;
|
break;
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
if ((old_data = zend_symtable_find(ht, Z_STR(key))) != NULL) {
|
||||||
var_push_dtor(var_hash, old_data);
|
var_push_dtor(var_hash, old_data);
|
||||||
}
|
}
|
||||||
zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
|
zend_symtable_update(ht, Z_STR(key), &data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* object properties should include no integers */
|
/* object properties should include no integers */
|
||||||
convert_to_string(key);
|
convert_to_string(&key);
|
||||||
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
|
zend_hash_update(ht, Z_STR(key), &data);
|
||||||
sizeof data, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
|
|
||||||
if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
|
if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
|
||||||
(*p)--;
|
(*p)--;
|
||||||
|
@ -377,8 +367,8 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ce->unserialize == NULL) {
|
if (ce->unserialize == NULL) {
|
||||||
zend_error(E_WARNING, "Class %s has no unserializer", ce->name);
|
zend_error(E_WARNING, "Class %s has no unserializer", ce->name->val);
|
||||||
object_init_ex(*rval, ce);
|
object_init_ex(rval, ce);
|
||||||
} else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) {
|
} else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +386,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
|
|
||||||
(*p) += 2;
|
(*p) += 2;
|
||||||
|
|
||||||
object_init_ex(*rval, ce);
|
object_init_ex(rval, ce);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,25 +395,23 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
#endif
|
#endif
|
||||||
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
||||||
{
|
{
|
||||||
zval *retval_ptr = NULL;
|
zval retval;
|
||||||
zval fname;
|
zval fname;
|
||||||
|
|
||||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) {
|
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_P(rval), elements, 1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
|
if (Z_OBJCE_P(rval) != PHP_IC_ENTRY &&
|
||||||
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) {
|
zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) {
|
||||||
INIT_PZVAL(&fname);
|
//??? ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
|
||||||
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
|
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1);
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
|
call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL TSRMLS_CC);
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval_ptr) {
|
zval_ptr_dtor(&retval);
|
||||||
zval_ptr_dtor(&retval_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -439,7 +427,7 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
||||||
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
{
|
{
|
||||||
const unsigned char *cursor, *limit, *marker, *start;
|
const unsigned char *cursor, *limit, *marker, *start;
|
||||||
zval **rval_ref;
|
zval *rval_ref;
|
||||||
|
|
||||||
limit = max;
|
limit = max;
|
||||||
cursor = *p;
|
cursor = *p;
|
||||||
|
@ -457,7 +445,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line 461 "ext/standard/var_unserializer.c"
|
#line 449 "ext/standard/var_unserializer.c"
|
||||||
{
|
{
|
||||||
YYCTYPE yych;
|
YYCTYPE yych;
|
||||||
static const unsigned char yybm[] = {
|
static const unsigned char yybm[] = {
|
||||||
|
@ -517,9 +505,9 @@ yy2:
|
||||||
yych = *(YYMARKER = ++YYCURSOR);
|
yych = *(YYMARKER = ++YYCURSOR);
|
||||||
if (yych == ':') goto yy95;
|
if (yych == ':') goto yy95;
|
||||||
yy3:
|
yy3:
|
||||||
#line 812 "ext/standard/var_unserializer.re"
|
#line 785 "ext/standard/var_unserializer.re"
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
#line 523 "ext/standard/var_unserializer.c"
|
#line 511 "ext/standard/var_unserializer.c"
|
||||||
yy4:
|
yy4:
|
||||||
yych = *(YYMARKER = ++YYCURSOR);
|
yych = *(YYMARKER = ++YYCURSOR);
|
||||||
if (yych == ':') goto yy89;
|
if (yych == ':') goto yy89;
|
||||||
|
@ -562,13 +550,13 @@ yy13:
|
||||||
goto yy3;
|
goto yy3;
|
||||||
yy14:
|
yy14:
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 806 "ext/standard/var_unserializer.re"
|
#line 779 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
/* this is the case where we have less data than planned */
|
/* this is the case where we have less data than planned */
|
||||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
|
||||||
return 0; /* not sure if it should be 0 or 1 here? */
|
return 0; /* not sure if it should be 0 or 1 here? */
|
||||||
}
|
}
|
||||||
#line 572 "ext/standard/var_unserializer.c"
|
#line 560 "ext/standard/var_unserializer.c"
|
||||||
yy16:
|
yy16:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
goto yy3;
|
goto yy3;
|
||||||
|
@ -598,27 +586,26 @@ yy20:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != '"') goto yy18;
|
if (yych != '"') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 660 "ext/standard/var_unserializer.re"
|
#line 641 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
size_t len, len2, len3, maxlen;
|
size_t len, len2, len3, maxlen;
|
||||||
long elements;
|
long elements;
|
||||||
char *class_name;
|
char *str;
|
||||||
|
zend_string *class_name;
|
||||||
zend_class_entry *ce;
|
zend_class_entry *ce;
|
||||||
zend_class_entry **pce;
|
|
||||||
int incomplete_class = 0;
|
int incomplete_class = 0;
|
||||||
|
|
||||||
int custom_object = 0;
|
int custom_object = 0;
|
||||||
|
|
||||||
zval *user_func;
|
zval user_func;
|
||||||
zval *retval_ptr;
|
zval retval;
|
||||||
zval **args[1];
|
zval args[1];
|
||||||
zval *arg_func_name;
|
|
||||||
|
|
||||||
if (*start == 'C') {
|
if (*start == 'C') {
|
||||||
custom_object = 1;
|
custom_object = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? INIT_PZVAL(rval);
|
||||||
len2 = len = parse_uiv(start + 2);
|
len2 = len = parse_uiv(start + 2);
|
||||||
maxlen = max - YYCURSOR;
|
maxlen = max - YYCURSOR;
|
||||||
if (maxlen < len || len == 0) {
|
if (maxlen < len || len == 0) {
|
||||||
|
@ -626,7 +613,7 @@ yy20:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class_name = (char*)YYCURSOR;
|
str = (char*)YYCURSOR;
|
||||||
|
|
||||||
YYCURSOR += len;
|
YYCURSOR += len;
|
||||||
|
|
||||||
|
@ -639,31 +626,31 @@ yy20:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
|
len3 = strspn(str, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
|
||||||
if (len3 != len)
|
if (len3 != len)
|
||||||
{
|
{
|
||||||
*p = YYCURSOR + len3 - len;
|
*p = YYCURSOR + len3 - len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class_name = estrndup(class_name, len);
|
class_name = STR_INIT(str, len, 0);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Try to find class directly */
|
/* Try to find class directly */
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
|
ce = zend_lookup_class(class_name TSRMLS_CC);
|
||||||
|
if (ce) {
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_RELEASE(class_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ce = *pce;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_RELEASE(class_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,49 +662,42 @@ yy20:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call unserialize callback */
|
/* Call unserialize callback */
|
||||||
MAKE_STD_ZVAL(user_func);
|
ZVAL_STRING(&user_func, PG(unserialize_callback_func));
|
||||||
ZVAL_STRING(user_func, PG(unserialize_callback_func), 1);
|
ZVAL_STR(&args[0], class_name);
|
||||||
args[0] = &arg_func_name;
|
|
||||||
MAKE_STD_ZVAL(arg_func_name);
|
|
||||||
ZVAL_STRING(arg_func_name, class_name, 1);
|
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
|
if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val);
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func));
|
||||||
incomplete_class = 1;
|
incomplete_class = 1;
|
||||||
ce = PHP_IC_ENTRY;
|
ce = PHP_IC_ENTRY;
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (retval_ptr) {
|
zval_ptr_dtor(&retval);
|
||||||
zval_ptr_dtor(&retval_ptr);
|
|
||||||
}
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The callback function may have defined the class */
|
/* The callback function may have defined the class */
|
||||||
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
|
if ((ce = zend_lookup_class(class_name TSRMLS_CC)) == NULL) {
|
||||||
ce = *pce;
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func));
|
||||||
} else {
|
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val);
|
|
||||||
incomplete_class = 1;
|
incomplete_class = 1;
|
||||||
ce = PHP_IC_ENTRY;
|
ce = PHP_IC_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
break;
|
break;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
@ -729,22 +709,22 @@ yy20:
|
||||||
ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
|
ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
|
||||||
|
|
||||||
if (ret && incomplete_class) {
|
if (ret && incomplete_class) {
|
||||||
php_store_class_name(*rval, class_name, len2);
|
php_store_class_name(rval, class_name->val, len2);
|
||||||
}
|
}
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
|
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
|
||||||
|
|
||||||
if (incomplete_class) {
|
if (incomplete_class) {
|
||||||
php_store_class_name(*rval, class_name, len2);
|
php_store_class_name(rval, class_name->val, len2);
|
||||||
}
|
}
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
|
|
||||||
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
||||||
}
|
}
|
||||||
#line 748 "ext/standard/var_unserializer.c"
|
#line 728 "ext/standard/var_unserializer.c"
|
||||||
yy25:
|
yy25:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= ',') {
|
if (yych <= ',') {
|
||||||
|
@ -769,15 +749,15 @@ yy27:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != '"') goto yy18;
|
if (yych != '"') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 652 "ext/standard/var_unserializer.re"
|
#line 633 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? INIT_PZVAL(rval);
|
||||||
|
|
||||||
return object_common2(UNSERIALIZE_PASSTHRU,
|
return object_common2(UNSERIALIZE_PASSTHRU,
|
||||||
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
||||||
}
|
}
|
||||||
#line 781 "ext/standard/var_unserializer.c"
|
#line 761 "ext/standard/var_unserializer.c"
|
||||||
yy32:
|
yy32:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych == '+') goto yy33;
|
if (yych == '+') goto yy33;
|
||||||
|
@ -798,7 +778,7 @@ yy34:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != '{') goto yy18;
|
if (yych != '{') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 632 "ext/standard/var_unserializer.re"
|
#line 615 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
long elements = parse_iv(start + 2);
|
long elements = parse_iv(start + 2);
|
||||||
/* use iv() not uiv() in order to check data range */
|
/* use iv() not uiv() in order to check data range */
|
||||||
|
@ -808,17 +788,15 @@ yy34:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
array_init_size(rval, elements);
|
||||||
|
|
||||||
array_init_size(*rval, elements);
|
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) {
|
||||||
|
|
||||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_PP(rval), elements, 0)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
||||||
}
|
}
|
||||||
#line 822 "ext/standard/var_unserializer.c"
|
#line 800 "ext/standard/var_unserializer.c"
|
||||||
yy39:
|
yy39:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych == '+') goto yy40;
|
if (yych == '+') goto yy40;
|
||||||
|
@ -839,7 +817,7 @@ yy41:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != '"') goto yy18;
|
if (yych != '"') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 603 "ext/standard/var_unserializer.re"
|
#line 586 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
size_t len, maxlen;
|
size_t len, maxlen;
|
||||||
char *str;
|
char *str;
|
||||||
|
@ -864,11 +842,11 @@ yy41:
|
||||||
YYCURSOR += 2;
|
YYCURSOR += 2;
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? ZVAL_STRINGL(rval, str, len, 0);
|
||||||
ZVAL_STRINGL(*rval, str, len, 0);
|
ZVAL_STRINGL(rval, str, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 872 "ext/standard/var_unserializer.c"
|
#line 850 "ext/standard/var_unserializer.c"
|
||||||
yy46:
|
yy46:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych == '+') goto yy47;
|
if (yych == '+') goto yy47;
|
||||||
|
@ -889,7 +867,7 @@ yy48:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != '"') goto yy18;
|
if (yych != '"') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 575 "ext/standard/var_unserializer.re"
|
#line 559 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
size_t len, maxlen;
|
size_t len, maxlen;
|
||||||
char *str;
|
char *str;
|
||||||
|
@ -913,11 +891,10 @@ yy48:
|
||||||
YYCURSOR += 2;
|
YYCURSOR += 2;
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_STRINGL(rval, str, len);
|
||||||
ZVAL_STRINGL(*rval, str, len, 1);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 921 "ext/standard/var_unserializer.c"
|
#line 898 "ext/standard/var_unserializer.c"
|
||||||
yy53:
|
yy53:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= '/') {
|
if (yych <= '/') {
|
||||||
|
@ -1005,17 +982,16 @@ yy61:
|
||||||
}
|
}
|
||||||
yy63:
|
yy63:
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 565 "ext/standard/var_unserializer.re"
|
#line 550 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
#if SIZEOF_LONG == 4
|
#if SIZEOF_LONG == 4
|
||||||
use_double:
|
use_double:
|
||||||
#endif
|
#endif
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
|
||||||
ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1019 "ext/standard/var_unserializer.c"
|
#line 995 "ext/standard/var_unserializer.c"
|
||||||
yy65:
|
yy65:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= ',') {
|
if (yych <= ',') {
|
||||||
|
@ -1074,22 +1050,23 @@ yy73:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != ';') goto yy18;
|
if (yych != ';') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 550 "ext/standard/var_unserializer.re"
|
#line 534 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
|
||||||
|
|
||||||
if (!strncmp(start + 2, "NAN", 3)) {
|
if (!strncmp((char*)start + 2, "NAN", 3)) {
|
||||||
ZVAL_DOUBLE(*rval, php_get_nan());
|
ZVAL_DOUBLE(rval, php_get_nan());
|
||||||
} else if (!strncmp(start + 2, "INF", 3)) {
|
} else if (!strncmp((char*)start + 2, "INF", 3)) {
|
||||||
ZVAL_DOUBLE(*rval, php_get_inf());
|
ZVAL_DOUBLE(rval, php_get_inf());
|
||||||
} else if (!strncmp(start + 2, "-INF", 4)) {
|
} else if (!strncmp((char*)start + 2, "-INF", 4)) {
|
||||||
ZVAL_DOUBLE(*rval, -php_get_inf());
|
ZVAL_DOUBLE(rval, -php_get_inf());
|
||||||
|
} else {
|
||||||
|
ZVAL_NULL(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1093 "ext/standard/var_unserializer.c"
|
#line 1070 "ext/standard/var_unserializer.c"
|
||||||
yy76:
|
yy76:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych == 'N') goto yy73;
|
if (yych == 'N') goto yy73;
|
||||||
|
@ -1116,7 +1093,7 @@ yy79:
|
||||||
if (yych <= '9') goto yy79;
|
if (yych <= '9') goto yy79;
|
||||||
if (yych != ';') goto yy18;
|
if (yych != ';') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 523 "ext/standard/var_unserializer.re"
|
#line 508 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
#if SIZEOF_LONG == 4
|
#if SIZEOF_LONG == 4
|
||||||
int digits = YYCURSOR - start - 3;
|
int digits = YYCURSOR - start - 3;
|
||||||
|
@ -1128,7 +1105,7 @@ yy79:
|
||||||
/* Use double for large long values that were serialized on a 64-bit system */
|
/* Use double for large long values that were serialized on a 64-bit system */
|
||||||
if (digits >= MAX_LENGTH_OF_LONG - 1) {
|
if (digits >= MAX_LENGTH_OF_LONG - 1) {
|
||||||
if (digits == MAX_LENGTH_OF_LONG - 1) {
|
if (digits == MAX_LENGTH_OF_LONG - 1) {
|
||||||
int cmp = strncmp(YYCURSOR - MAX_LENGTH_OF_LONG, long_min_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] == '-'))) {
|
if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {
|
||||||
goto use_double;
|
goto use_double;
|
||||||
|
@ -1139,11 +1116,10 @@ yy79:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_LONG(rval, parse_iv(start + 2));
|
||||||
ZVAL_LONG(*rval, parse_iv(start + 2));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1147 "ext/standard/var_unserializer.c"
|
#line 1123 "ext/standard/var_unserializer.c"
|
||||||
yy83:
|
yy83:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= '/') goto yy18;
|
if (yych <= '/') goto yy18;
|
||||||
|
@ -1151,24 +1127,22 @@ yy83:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych != ';') goto yy18;
|
if (yych != ';') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 516 "ext/standard/var_unserializer.re"
|
#line 502 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_BOOL(rval, parse_iv(start + 2));
|
||||||
ZVAL_BOOL(*rval, parse_iv(start + 2));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1162 "ext/standard/var_unserializer.c"
|
#line 1137 "ext/standard/var_unserializer.c"
|
||||||
yy87:
|
yy87:
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 509 "ext/standard/var_unserializer.re"
|
#line 496 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_NULL(rval);
|
||||||
ZVAL_NULL(*rval);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1172 "ext/standard/var_unserializer.c"
|
#line 1146 "ext/standard/var_unserializer.c"
|
||||||
yy89:
|
yy89:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= ',') {
|
if (yych <= ',') {
|
||||||
|
@ -1191,7 +1165,7 @@ yy91:
|
||||||
if (yych <= '9') goto yy91;
|
if (yych <= '9') goto yy91;
|
||||||
if (yych != ';') goto yy18;
|
if (yych != ';') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 486 "ext/standard/var_unserializer.re"
|
#line 473 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
|
@ -1203,18 +1177,18 @@ yy91:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*rval == *rval_ref) return 0;
|
//???
|
||||||
|
if (rval == rval_ref) return 0;
|
||||||
|
|
||||||
if (*rval != NULL) {
|
if (rval != NULL) {
|
||||||
var_push_dtor_no_addref(var_hash, rval);
|
var_push_dtor_no_addref(var_hash, rval);
|
||||||
}
|
}
|
||||||
*rval = *rval_ref;
|
ZVAL_COPY(rval, rval_ref);
|
||||||
Z_ADDREF_PP(rval);
|
//??? Z_UNSET_ISREF_PP(rval);
|
||||||
Z_UNSET_ISREF_PP(rval);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1218 "ext/standard/var_unserializer.c"
|
#line 1192 "ext/standard/var_unserializer.c"
|
||||||
yy95:
|
yy95:
|
||||||
yych = *++YYCURSOR;
|
yych = *++YYCURSOR;
|
||||||
if (yych <= ',') {
|
if (yych <= ',') {
|
||||||
|
@ -1237,7 +1211,7 @@ yy97:
|
||||||
if (yych <= '9') goto yy97;
|
if (yych <= '9') goto yy97;
|
||||||
if (yych != ';') goto yy18;
|
if (yych != ';') goto yy18;
|
||||||
++YYCURSOR;
|
++YYCURSOR;
|
||||||
#line 465 "ext/standard/var_unserializer.re"
|
#line 453 "ext/standard/var_unserializer.re"
|
||||||
{
|
{
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
|
@ -1249,18 +1223,17 @@ yy97:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*rval != NULL) {
|
if (rval != NULL) {
|
||||||
zval_ptr_dtor(rval);
|
zval_ptr_dtor(rval);
|
||||||
}
|
}
|
||||||
*rval = *rval_ref;
|
ZVAL_COPY(rval, rval_ref);
|
||||||
Z_ADDREF_PP(rval);
|
//??? Z_SET_ISREF_PP(rval);
|
||||||
Z_SET_ISREF_PP(rval);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#line 1262 "ext/standard/var_unserializer.c"
|
#line 1235 "ext/standard/var_unserializer.c"
|
||||||
}
|
}
|
||||||
#line 814 "ext/standard/var_unserializer.re"
|
#line 787 "ext/standard/var_unserializer.re"
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef struct {
|
||||||
void *next;
|
void *next;
|
||||||
} var_entries;
|
} var_entries;
|
||||||
|
|
||||||
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
static inline void var_push(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last;
|
var_entries *var_hash = (*var_hashx)->last;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -53,10 +53,10 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
|
||||||
(*var_hashx)->last = var_hash;
|
(*var_hashx)->last = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
|
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last_dtor;
|
var_entries *var_hash = (*var_hashx)->last_dtor;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -77,11 +77,11 @@ PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
|
||||||
(*var_hashx)->last_dtor = var_hash;
|
(*var_hashx)->last_dtor = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_ADDREF_PP(rval);
|
Z_ADDREF_P(rval);
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval)
|
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval *rval)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->last_dtor;
|
var_entries *var_hash = (*var_hashx)->last_dtor;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -102,10 +102,10 @@ PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rv
|
||||||
(*var_hashx)->last_dtor = var_hash;
|
(*var_hashx)->last_dtor = var_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
var_hash->data[var_hash->used_slots++] = *rval;
|
var_hash->data[var_hash->used_slots++] = rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval)
|
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval *nzval)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
var_entries *var_hash = (*var_hashx)->first;
|
var_entries *var_hash = (*var_hashx)->first;
|
||||||
|
@ -116,7 +116,7 @@ PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **n
|
||||||
while (var_hash) {
|
while (var_hash) {
|
||||||
for (i = 0; i < var_hash->used_slots; i++) {
|
for (i = 0; i < var_hash->used_slots; i++) {
|
||||||
if (var_hash->data[i] == ozval) {
|
if (var_hash->data[i] == ozval) {
|
||||||
var_hash->data[i] = *nzval;
|
var_hash->data[i] = nzval;
|
||||||
/* do not break here */
|
/* do not break here */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,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, long id, zval ***store)
|
static int var_access(php_unserialize_data_t *var_hashx, long id, zval **store)
|
||||||
{
|
{
|
||||||
var_entries *var_hash = (*var_hashx)->first;
|
var_entries *var_hash = (*var_hashx)->first;
|
||||||
#if VAR_ENTRIES_DBG
|
#if VAR_ENTRIES_DBG
|
||||||
|
@ -140,7 +140,7 @@ static int var_access(php_unserialize_data_t *var_hashx, long id, zval ***store)
|
||||||
|
|
||||||
if (id < 0 || id >= var_hash->used_slots) return !SUCCESS;
|
if (id < 0 || id >= var_hash->used_slots) return !SUCCESS;
|
||||||
|
|
||||||
*store = &var_hash->data[id];
|
*store = var_hash->data[id];
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
|
||||||
|
|
||||||
while (var_hash) {
|
while (var_hash) {
|
||||||
for (i = 0; i < var_hash->used_slots; i++) {
|
for (i = 0; i < var_hash->used_slots; i++) {
|
||||||
zval_ptr_dtor(&var_hash->data[i]);
|
zval_ptr_dtor(var_hash->data[i]);
|
||||||
}
|
}
|
||||||
next = var_hash->next;
|
next = var_hash->next;
|
||||||
efree(var_hash);
|
efree(var_hash);
|
||||||
|
@ -290,62 +290,52 @@ static inline size_t parse_uiv(const unsigned char *p)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNSERIALIZE_PARAMETER zval **rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC
|
#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
|
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash TSRMLS_CC
|
||||||
|
|
||||||
static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
|
static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
|
||||||
{
|
{
|
||||||
while (elements-- > 0) {
|
while (elements-- > 0) {
|
||||||
zval *key, *data, **old_data;
|
zval key, data, *old_data;
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(key);
|
|
||||||
|
|
||||||
if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
|
if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {
|
if (Z_TYPE(key) != IS_LONG && Z_TYPE(key) != IS_STRING) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(data);
|
|
||||||
|
|
||||||
if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
|
if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
zval_dtor(&data);
|
||||||
zval_dtor(data);
|
|
||||||
FREE_ZVAL(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!objprops) {
|
if (!objprops) {
|
||||||
switch (Z_TYPE_P(key)) {
|
switch (Z_TYPE(key)) {
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
if (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {
|
if ((old_data = zend_hash_index_find(ht, Z_LVAL(key))) != NULL) {
|
||||||
var_push_dtor(var_hash, old_data);
|
var_push_dtor(var_hash, old_data);
|
||||||
}
|
}
|
||||||
zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
|
zend_hash_index_update(ht, Z_LVAL(key), &data);
|
||||||
break;
|
break;
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
if ((old_data = zend_symtable_find(ht, Z_STR(key))) != NULL) {
|
||||||
var_push_dtor(var_hash, old_data);
|
var_push_dtor(var_hash, old_data);
|
||||||
}
|
}
|
||||||
zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
|
zend_symtable_update(ht, Z_STR(key), &data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* object properties should include no integers */
|
/* object properties should include no integers */
|
||||||
convert_to_string(key);
|
convert_to_string(&key);
|
||||||
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
|
zend_hash_update(ht, Z_STR(key), &data);
|
||||||
sizeof data, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zval_dtor(key);
|
zval_dtor(&key);
|
||||||
FREE_ZVAL(key);
|
|
||||||
|
|
||||||
if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
|
if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
|
||||||
(*p)--;
|
(*p)--;
|
||||||
|
@ -381,8 +371,8 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ce->unserialize == NULL) {
|
if (ce->unserialize == NULL) {
|
||||||
zend_error(E_WARNING, "Class %s has no unserializer", ce->name);
|
zend_error(E_WARNING, "Class %s has no unserializer", ce->name->val);
|
||||||
object_init_ex(*rval, ce);
|
object_init_ex(rval, ce);
|
||||||
} else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) {
|
} else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +390,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
|
|
||||||
(*p) += 2;
|
(*p) += 2;
|
||||||
|
|
||||||
object_init_ex(*rval, ce);
|
object_init_ex(rval, ce);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,25 +399,23 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
||||||
#endif
|
#endif
|
||||||
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
||||||
{
|
{
|
||||||
zval *retval_ptr = NULL;
|
zval retval;
|
||||||
zval fname;
|
zval fname;
|
||||||
|
|
||||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) {
|
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_P(rval), elements, 1)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
|
if (Z_OBJCE_P(rval) != PHP_IC_ENTRY &&
|
||||||
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) {
|
zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) {
|
||||||
INIT_PZVAL(&fname);
|
//??? ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
|
||||||
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
|
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1);
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
|
call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL TSRMLS_CC);
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval_ptr) {
|
zval_ptr_dtor(&retval);
|
||||||
zval_ptr_dtor(&retval_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -443,7 +431,7 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
|
||||||
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
{
|
{
|
||||||
const unsigned char *cursor, *limit, *marker, *start;
|
const unsigned char *cursor, *limit, *marker, *start;
|
||||||
zval **rval_ref;
|
zval *rval_ref;
|
||||||
|
|
||||||
limit = max;
|
limit = max;
|
||||||
cursor = *p;
|
cursor = *p;
|
||||||
|
@ -473,12 +461,11 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*rval != NULL) {
|
if (rval != NULL) {
|
||||||
zval_ptr_dtor(rval);
|
zval_ptr_dtor(rval);
|
||||||
}
|
}
|
||||||
*rval = *rval_ref;
|
ZVAL_COPY(rval, rval_ref);
|
||||||
Z_ADDREF_PP(rval);
|
//??? Z_SET_ISREF_PP(rval);
|
||||||
Z_SET_ISREF_PP(rval);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -494,29 +481,27 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*rval == *rval_ref) return 0;
|
//???
|
||||||
|
if (rval == rval_ref) return 0;
|
||||||
|
|
||||||
if (*rval != NULL) {
|
if (rval != NULL) {
|
||||||
var_push_dtor_no_addref(var_hash, rval);
|
var_push_dtor_no_addref(var_hash, rval);
|
||||||
}
|
}
|
||||||
*rval = *rval_ref;
|
ZVAL_COPY(rval, rval_ref);
|
||||||
Z_ADDREF_PP(rval);
|
//??? Z_UNSET_ISREF_PP(rval);
|
||||||
Z_UNSET_ISREF_PP(rval);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
"N;" {
|
"N;" {
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_NULL(rval);
|
||||||
ZVAL_NULL(*rval);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
"b:" [01] ";" {
|
"b:" [01] ";" {
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_BOOL(rval, parse_iv(start + 2));
|
||||||
ZVAL_BOOL(*rval, parse_iv(start + 2));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +516,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
/* Use double for large long values that were serialized on a 64-bit system */
|
/* Use double for large long values that were serialized on a 64-bit system */
|
||||||
if (digits >= MAX_LENGTH_OF_LONG - 1) {
|
if (digits >= MAX_LENGTH_OF_LONG - 1) {
|
||||||
if (digits == MAX_LENGTH_OF_LONG - 1) {
|
if (digits == MAX_LENGTH_OF_LONG - 1) {
|
||||||
int cmp = strncmp(YYCURSOR - MAX_LENGTH_OF_LONG, long_min_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] == '-'))) {
|
if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) {
|
||||||
goto use_double;
|
goto use_double;
|
||||||
|
@ -542,21 +527,21 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_LONG(rval, parse_iv(start + 2));
|
||||||
ZVAL_LONG(*rval, parse_iv(start + 2));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
"d:" ("NAN" | "-"? "INF") ";" {
|
"d:" ("NAN" | "-"? "INF") ";" {
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
|
||||||
|
|
||||||
if (!strncmp(start + 2, "NAN", 3)) {
|
if (!strncmp((char*)start + 2, "NAN", 3)) {
|
||||||
ZVAL_DOUBLE(*rval, php_get_nan());
|
ZVAL_DOUBLE(rval, php_get_nan());
|
||||||
} else if (!strncmp(start + 2, "INF", 3)) {
|
} else if (!strncmp((char*)start + 2, "INF", 3)) {
|
||||||
ZVAL_DOUBLE(*rval, php_get_inf());
|
ZVAL_DOUBLE(rval, php_get_inf());
|
||||||
} else if (!strncmp(start + 2, "-INF", 4)) {
|
} else if (!strncmp((char*)start + 2, "-INF", 4)) {
|
||||||
ZVAL_DOUBLE(*rval, -php_get_inf());
|
ZVAL_DOUBLE(rval, -php_get_inf());
|
||||||
|
} else {
|
||||||
|
ZVAL_NULL(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -567,8 +552,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
|
||||||
use_double:
|
use_double:
|
||||||
#endif
|
#endif
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
|
||||||
ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +579,7 @@ use_double:
|
||||||
YYCURSOR += 2;
|
YYCURSOR += 2;
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
ZVAL_STRINGL(rval, str, len);
|
||||||
ZVAL_STRINGL(*rval, str, len, 1);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,8 +607,8 @@ use_double:
|
||||||
YYCURSOR += 2;
|
YYCURSOR += 2;
|
||||||
*p = YYCURSOR;
|
*p = YYCURSOR;
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? ZVAL_STRINGL(rval, str, len, 0);
|
||||||
ZVAL_STRINGL(*rval, str, len, 0);
|
ZVAL_STRINGL(rval, str, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,11 +621,9 @@ use_double:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
array_init_size(rval, elements);
|
||||||
|
|
||||||
array_init_size(*rval, elements);
|
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) {
|
||||||
|
|
||||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_PP(rval), elements, 0)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +632,7 @@ use_double:
|
||||||
|
|
||||||
"o:" iv ":" ["] {
|
"o:" iv ":" ["] {
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? INIT_PZVAL(rval);
|
||||||
|
|
||||||
return object_common2(UNSERIALIZE_PASSTHRU,
|
return object_common2(UNSERIALIZE_PASSTHRU,
|
||||||
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
||||||
|
@ -660,23 +641,22 @@ use_double:
|
||||||
object ":" uiv ":" ["] {
|
object ":" uiv ":" ["] {
|
||||||
size_t len, len2, len3, maxlen;
|
size_t len, len2, len3, maxlen;
|
||||||
long elements;
|
long elements;
|
||||||
char *class_name;
|
char *str;
|
||||||
|
zend_string *class_name;
|
||||||
zend_class_entry *ce;
|
zend_class_entry *ce;
|
||||||
zend_class_entry **pce;
|
|
||||||
int incomplete_class = 0;
|
int incomplete_class = 0;
|
||||||
|
|
||||||
int custom_object = 0;
|
int custom_object = 0;
|
||||||
|
|
||||||
zval *user_func;
|
zval user_func;
|
||||||
zval *retval_ptr;
|
zval retval;
|
||||||
zval **args[1];
|
zval args[1];
|
||||||
zval *arg_func_name;
|
|
||||||
|
|
||||||
if (*start == 'C') {
|
if (*start == 'C') {
|
||||||
custom_object = 1;
|
custom_object = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_PZVAL(*rval);
|
//??? INIT_PZVAL(rval);
|
||||||
len2 = len = parse_uiv(start + 2);
|
len2 = len = parse_uiv(start + 2);
|
||||||
maxlen = max - YYCURSOR;
|
maxlen = max - YYCURSOR;
|
||||||
if (maxlen < len || len == 0) {
|
if (maxlen < len || len == 0) {
|
||||||
|
@ -684,7 +664,7 @@ object ":" uiv ":" ["] {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class_name = (char*)YYCURSOR;
|
str = (char*)YYCURSOR;
|
||||||
|
|
||||||
YYCURSOR += len;
|
YYCURSOR += len;
|
||||||
|
|
||||||
|
@ -697,31 +677,31 @@ object ":" uiv ":" ["] {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len3 = strspn(class_name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
|
len3 = strspn(str, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\");
|
||||||
if (len3 != len)
|
if (len3 != len)
|
||||||
{
|
{
|
||||||
*p = YYCURSOR + len3 - len;
|
*p = YYCURSOR + len3 - len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class_name = estrndup(class_name, len);
|
class_name = STR_INIT(str, len, 0);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Try to find class directly */
|
/* Try to find class directly */
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
|
ce = zend_lookup_class(class_name TSRMLS_CC);
|
||||||
|
if (ce) {
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_RELEASE(class_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ce = *pce;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_RELEASE(class_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,49 +713,42 @@ object ":" uiv ":" ["] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call unserialize callback */
|
/* Call unserialize callback */
|
||||||
MAKE_STD_ZVAL(user_func);
|
ZVAL_STRING(&user_func, PG(unserialize_callback_func));
|
||||||
ZVAL_STRING(user_func, PG(unserialize_callback_func), 1);
|
ZVAL_STR(&args[0], class_name);
|
||||||
args[0] = &arg_func_name;
|
|
||||||
MAKE_STD_ZVAL(arg_func_name);
|
|
||||||
ZVAL_STRING(arg_func_name, class_name, 1);
|
|
||||||
BG(serialize_lock)++;
|
BG(serialize_lock)++;
|
||||||
if (call_user_function_ex(CG(function_table), NULL, user_func, &retval_ptr, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
|
if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) {
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", user_func->value.str.val);
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func));
|
||||||
incomplete_class = 1;
|
incomplete_class = 1;
|
||||||
ce = PHP_IC_ENTRY;
|
ce = PHP_IC_ENTRY;
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BG(serialize_lock)--;
|
BG(serialize_lock)--;
|
||||||
if (retval_ptr) {
|
zval_ptr_dtor(&retval);
|
||||||
zval_ptr_dtor(&retval_ptr);
|
|
||||||
}
|
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The callback function may have defined the class */
|
/* The callback function may have defined the class */
|
||||||
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
|
if ((ce = zend_lookup_class(class_name TSRMLS_CC)) == NULL) {
|
||||||
ce = *pce;
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func));
|
||||||
} else {
|
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function %s() hasn't defined the class it was called for", user_func->value.str.val);
|
|
||||||
incomplete_class = 1;
|
incomplete_class = 1;
|
||||||
ce = PHP_IC_ENTRY;
|
ce = PHP_IC_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval_ptr_dtor(&user_func);
|
zval_ptr_dtor(&user_func);
|
||||||
zval_ptr_dtor(&arg_func_name);
|
zval_ptr_dtor(&args[0]);
|
||||||
break;
|
break;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
@ -787,18 +760,18 @@ object ":" uiv ":" ["] {
|
||||||
ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
|
ret = object_custom(UNSERIALIZE_PASSTHRU, ce);
|
||||||
|
|
||||||
if (ret && incomplete_class) {
|
if (ret && incomplete_class) {
|
||||||
php_store_class_name(*rval, class_name, len2);
|
php_store_class_name(rval, class_name->val, len2);
|
||||||
}
|
}
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
|
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
|
||||||
|
|
||||||
if (incomplete_class) {
|
if (incomplete_class) {
|
||||||
php_store_class_name(*rval, class_name, len2);
|
php_store_class_name(rval, class_name->val, len2);
|
||||||
}
|
}
|
||||||
efree(class_name);
|
STR_FREE(class_name);
|
||||||
|
|
||||||
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
|
||||||
FG(default_context) ? FG(default_context) : \
|
FG(default_context) ? FG(default_context) : \
|
||||||
(FG(default_context) = php_stream_context_alloc(TSRMLS_C)) )
|
(FG(default_context) = php_stream_context_alloc(TSRMLS_C)) )
|
||||||
|
|
||||||
#define php_stream_context_to_zval(context, zval) { ZVAL_RESOURCE(zval, (context)->res); zend_list_addref((context)->res); }
|
#define php_stream_context_to_zval(context, zval) { ZVAL_RES(zval, (context)->res); (context)->res->gc.refcount++; }
|
||||||
|
|
||||||
typedef struct _php_stream_notifier php_stream_notifier;
|
typedef struct _php_stream_notifier php_stream_notifier;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue