mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'master' into native-tls
* master: (23 commits) move the test to the right place fix TS build and C89 compat updated NEWS Fixed bug #68545 NULL pointer dereference in unserialize.c Updated NEWS Updated NEWS Updated NEWS NEWS Fix bug #68526 Implement POSIX Access Control List for UDS Improved basic zval copying primitives: ZVAL_COPY_VALUE(), ZVAL_COPY(), ZVAL_DUP() Wrap RETURN_VALUE_USED() with EXPECTED() or UNEXPECTED() macros according to more frequent usage patterns. Improved ASSIGN_<OP>, ASSIGN_DIM and UNSET_DIM drop dead/unused code simplified code Move ZVAL_DEREF() and make_real_object() into slow paths. Pass znode_op structure by value (it fits into one word) instead of pointer to structure. Move checks for references into slow paths. Improved ASSIGN_DIM and ASSIGN_OBJ Fixed typo Move checks for references into slow paths of handlers or helpers. Remove duplicate opcode handlers. ...
This commit is contained in:
commit
e087d3ac7f
33 changed files with 5669 additions and 7589 deletions
7
NEWS
7
NEWS
|
@ -23,6 +23,10 @@ PHP NEWS
|
|||
. Fixed bug #68185 ("Inconsistent insteadof definition."- incorrectly triggered). (Julien)
|
||||
. Fixed bug #65419 (Inside trait, self::class != __CLASS__). (Julien)
|
||||
|
||||
- Date:
|
||||
. Fixed day_of_week function as it could sometimes return negative values
|
||||
internally. (Derick)
|
||||
|
||||
- DBA:
|
||||
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
|
||||
|
||||
|
@ -44,6 +48,9 @@ PHP NEWS
|
|||
- LiteSpeed:
|
||||
. Updated LiteSpeed SAPI code from V5.5 to V6.6. (George Wang)
|
||||
|
||||
- Mcrypt:
|
||||
. Fixed possible read after end of buffer and use after free. (Dmitry)
|
||||
|
||||
- pcntl:
|
||||
. Fixed bug #60509 (pcntl_signal doesn't decrease ref-count of old handler
|
||||
when setting SIG_DFL). (Julien)
|
||||
|
|
51
Zend/tests/generators/yield_precedence.phpt
Normal file
51
Zend/tests/generators/yield_precedence.phpt
Normal file
|
@ -0,0 +1,51 @@
|
|||
--TEST--
|
||||
Precedence of yield and arrow operators
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function gen() {
|
||||
yield "a" . "b";
|
||||
yield "a" or die;
|
||||
yield "k" => "a" . "b";
|
||||
yield "k" => "a" or die;
|
||||
var_dump([yield "k" => "a" . "b"]);
|
||||
yield yield "k1" => yield "k2" => "a" . "b";
|
||||
yield yield "k1" => (yield "k2") => "a" . "b";
|
||||
var_dump([yield "k1" => yield "k2" => "a" . "b"]);
|
||||
var_dump([yield "k1" => (yield "k2") => "a" . "b"]);
|
||||
}
|
||||
|
||||
$g = gen();
|
||||
for ($g->rewind(), $i = 1; $g->valid(); $g->send($i), $i++) {
|
||||
echo "{$g->key()} => {$g->current()}\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
0 => ab
|
||||
1 => a
|
||||
k => ab
|
||||
k => a
|
||||
k => ab
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(5)
|
||||
}
|
||||
k2 => ab
|
||||
k1 => 6
|
||||
2 => 7
|
||||
3 => k2
|
||||
k1 => 9
|
||||
10 => ab
|
||||
k2 => ab
|
||||
k1 => 12
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(13)
|
||||
}
|
||||
11 => k2
|
||||
k1 => 14
|
||||
array(1) {
|
||||
[15]=>
|
||||
string(2) "ab"
|
||||
}
|
|
@ -390,41 +390,43 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execu
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
{
|
||||
switch (op_type) {
|
||||
case IS_CONST:
|
||||
*should_free = NULL;
|
||||
return node->zv;
|
||||
case IS_TMP_VAR:
|
||||
return _get_zval_ptr_tmp(node->var, execute_data, should_free);
|
||||
case IS_VAR:
|
||||
return _get_zval_ptr_var(node->var, execute_data, should_free);
|
||||
case IS_CV:
|
||||
*should_free = NULL;
|
||||
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);
|
||||
default:
|
||||
*should_free = NULL;
|
||||
return NULL;
|
||||
if (op_type & (IS_TMP_VAR|IS_VAR)) {
|
||||
if (op_type == IS_TMP_VAR) {
|
||||
return _get_zval_ptr_tmp(node.var, execute_data, should_free);
|
||||
} else {
|
||||
ZEND_ASSERT(op_type == IS_VAR);
|
||||
return _get_zval_ptr_var(node.var, execute_data, should_free);
|
||||
}
|
||||
} else {
|
||||
*should_free = NULL;
|
||||
if (op_type == IS_CONST) {
|
||||
return node.zv;
|
||||
} else {
|
||||
ZEND_ASSERT(op_type == IS_CV);
|
||||
return _get_zval_ptr_cv(execute_data, node.var, type TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline zval *_get_zval_ptr_deref(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
static zend_always_inline zval *_get_zval_ptr_deref(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
{
|
||||
switch (op_type) {
|
||||
case IS_CONST:
|
||||
*should_free = NULL;
|
||||
return node->zv;
|
||||
case IS_TMP_VAR:
|
||||
return _get_zval_ptr_tmp(node->var, execute_data, should_free);
|
||||
case IS_VAR:
|
||||
return _get_zval_ptr_var_deref(node->var, execute_data, should_free);
|
||||
case IS_CV:
|
||||
*should_free = NULL;
|
||||
return _get_zval_ptr_cv_deref(execute_data, node->var, type TSRMLS_CC);
|
||||
default:
|
||||
*should_free = NULL;
|
||||
return NULL;
|
||||
if (op_type & (IS_TMP_VAR|IS_VAR)) {
|
||||
if (op_type == IS_TMP_VAR) {
|
||||
return _get_zval_ptr_tmp(node.var, execute_data, should_free);
|
||||
} else {
|
||||
ZEND_ASSERT(op_type == IS_VAR);
|
||||
return _get_zval_ptr_var_deref(node.var, execute_data, should_free);
|
||||
}
|
||||
} else {
|
||||
*should_free = NULL;
|
||||
if (op_type == IS_CONST) {
|
||||
return node.zv;
|
||||
} else {
|
||||
ZEND_ASSERT(op_type == IS_CV);
|
||||
return _get_zval_ptr_cv_deref(execute_data, node.var, type TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,14 +447,14 @@ static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var, const zend_e
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
{
|
||||
if (op_type == IS_CV) {
|
||||
*should_free = NULL;
|
||||
return _get_zval_ptr_cv(execute_data, node->var, type TSRMLS_CC);
|
||||
return _get_zval_ptr_cv(execute_data, node.var, type TSRMLS_CC);
|
||||
} else /* if (op_type == IS_VAR) */ {
|
||||
ZEND_ASSERT(op_type == IS_VAR);
|
||||
return _get_zval_ptr_ptr_var(node->var, execute_data, should_free);
|
||||
return _get_zval_ptr_ptr_var(node.var, execute_data, should_free);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +468,7 @@ static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *exec
|
|||
}
|
||||
}
|
||||
|
||||
static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
static inline zval *_get_obj_zval_ptr(int op_type, znode_op op, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
{
|
||||
if (op_type == IS_UNUSED) {
|
||||
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
|
||||
|
@ -479,7 +481,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, zend_execute_da
|
|||
return get_zval_ptr(op_type, op, execute_data, should_free, type);
|
||||
}
|
||||
|
||||
static inline zval *_get_obj_zval_ptr_ptr(int op_type, const znode_op *node, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
static inline zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
|
||||
{
|
||||
if (op_type == IS_UNUSED) {
|
||||
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
|
||||
|
@ -508,21 +510,23 @@ static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *v
|
|||
}
|
||||
|
||||
/* this should modify object only if it's empty */
|
||||
static inline zval* make_real_object(zval *object_ptr TSRMLS_DC)
|
||||
static inline int make_real_object(zval **object_ptr TSRMLS_DC)
|
||||
{
|
||||
zval *object = object_ptr;
|
||||
zval *object = *object_ptr;
|
||||
|
||||
ZVAL_DEREF(object);
|
||||
if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
|
||||
if (Z_TYPE_P(object) == IS_NULL
|
||||
|| Z_TYPE_P(object) == IS_FALSE
|
||||
if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE)
|
||||
|| (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) {
|
||||
zval_ptr_dtor_nogc(object);
|
||||
object_init(object);
|
||||
zend_error(E_WARNING, "Creating default object from empty value");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
*object_ptr = object;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ZEND_API char * zend_verify_internal_arg_class_kind(const zend_internal_arg_info *cur_arg_info, char **class_name, zend_class_entry **pce TSRMLS_DC)
|
||||
|
@ -759,25 +763,29 @@ static void zend_verify_missing_arg(zend_execute_data *execute_data, uint32_t ar
|
|||
}
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, int value_type, const znode_op *value_op, const zend_execute_data *execute_data, int opcode, void **cache_slot TSRMLS_DC)
|
||||
static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, uint32_t property_op_type, int value_type, znode_op value_op, const zend_execute_data *execute_data, void **cache_slot TSRMLS_DC)
|
||||
{
|
||||
zend_free_op free_value;
|
||||
zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
|
||||
zval tmp;
|
||||
|
||||
if (object_op_type != IS_UNUSED) {
|
||||
ZVAL_DEREF(object);
|
||||
if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
|
||||
if (UNEXPECTED(object == &EG(error_zval))) {
|
||||
if (retval) {
|
||||
ZVAL_NULL(retval);
|
||||
if (object_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
|
||||
do {
|
||||
if (object_op_type == IS_VAR && UNEXPECTED(object == &EG(error_zval))) {
|
||||
if (retval) {
|
||||
ZVAL_NULL(retval);
|
||||
}
|
||||
FREE_OP(free_value);
|
||||
return;
|
||||
}
|
||||
if (EXPECTED(Z_TYPE_P(object) == IS_NULL ||
|
||||
Z_TYPE_P(object) == IS_FALSE ||
|
||||
(Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
|
||||
if (Z_ISREF_P(object)) {
|
||||
object = Z_REFVAL_P(object);
|
||||
if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE ||
|
||||
(Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
|
||||
zend_object *obj;
|
||||
|
||||
zval_ptr_dtor(object);
|
||||
|
@ -803,107 +811,86 @@ static zend_always_inline void zend_assign_to_object(zval *retval, zval *object,
|
|||
FREE_OP(free_value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
if (opcode == ZEND_ASSIGN_OBJ) {
|
||||
if (!Z_OBJ_HT_P(object)->write_property) {
|
||||
zend_error(E_WARNING, "Attempt to assign property of non-object");
|
||||
if (retval) {
|
||||
ZVAL_NULL(retval);
|
||||
}
|
||||
FREE_OP(free_value);
|
||||
return;
|
||||
}
|
||||
if (property_op_type == IS_CONST &&
|
||||
EXPECTED(Z_OBJCE_P(object) == CACHED_PTR_EX(cache_slot))) {
|
||||
zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 1);
|
||||
zend_object *zobj = Z_OBJ_P(object);
|
||||
zval *property;
|
||||
|
||||
if (cache_slot &&
|
||||
EXPECTED(Z_OBJCE_P(object) == CACHED_PTR_EX(cache_slot))) {
|
||||
zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 1);
|
||||
zend_object *zobj = Z_OBJ_P(object);
|
||||
zval *property;
|
||||
|
||||
if (EXPECTED(prop_info)) {
|
||||
property = OBJ_PROP(zobj, prop_info->offset);
|
||||
if (Z_TYPE_P(property) != IS_UNDEF) {
|
||||
if (EXPECTED(prop_info)) {
|
||||
property = OBJ_PROP(zobj, prop_info->offset);
|
||||
if (Z_TYPE_P(property) != IS_UNDEF) {
|
||||
fast_assign:
|
||||
value = zend_assign_to_variable(property, value, value_type TSRMLS_CC);
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
if (value_type == IS_VAR) {
|
||||
FREE_OP(free_value);
|
||||
}
|
||||
return;
|
||||
value = zend_assign_to_variable(property, value, value_type TSRMLS_CC);
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
} else {
|
||||
if (EXPECTED(zobj->properties != NULL)) {
|
||||
property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
|
||||
if (property) {
|
||||
goto fast_assign;
|
||||
}
|
||||
if (value_type == IS_VAR) {
|
||||
FREE_OP(free_value);
|
||||
}
|
||||
|
||||
if (!zobj->ce->__set) {
|
||||
if (EXPECTED(zobj->properties == NULL)) {
|
||||
rebuild_object_properties(zobj);
|
||||
}
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
if (value_type == IS_VAR) {
|
||||
FREE_OP(free_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
return;
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
|
||||
Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot TSRMLS_CC);
|
||||
} else {
|
||||
/* Note: property_name in this case is really the array index! */
|
||||
if (!Z_OBJ_HT_P(object)->write_dimension) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot use object as array");
|
||||
}
|
||||
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
} else {
|
||||
if (EXPECTED(zobj->properties != NULL)) {
|
||||
property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
|
||||
if (property) {
|
||||
goto fast_assign;
|
||||
}
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
|
||||
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC);
|
||||
if (!zobj->ce->__set) {
|
||||
if (EXPECTED(zobj->properties == NULL)) {
|
||||
rebuild_object_properties(zobj);
|
||||
}
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
if (value_type == IS_VAR) {
|
||||
FREE_OP(free_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Z_OBJ_HT_P(object)->write_property) {
|
||||
zend_error(E_WARNING, "Attempt to assign property of non-object");
|
||||
if (retval) {
|
||||
ZVAL_NULL(retval);
|
||||
}
|
||||
FREE_OP(free_value);
|
||||
return;
|
||||
}
|
||||
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
|
||||
Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot TSRMLS_CC);
|
||||
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
|
@ -913,6 +900,73 @@ fast_assign:
|
|||
}
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_assign_to_object_dim(zval *retval, zval *object, zval *property_name, int value_type, znode_op value_op, const zend_execute_data *execute_data TSRMLS_DC)
|
||||
{
|
||||
zend_free_op free_value;
|
||||
zval *value = get_zval_ptr_deref(value_type, value_op, execute_data, &free_value, BP_VAR_R);
|
||||
zval tmp;
|
||||
|
||||
/* Note: property_name in this case is really the array index! */
|
||||
if (!Z_OBJ_HT_P(object)->write_dimension) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot use object as array");
|
||||
}
|
||||
|
||||
/* separate our value if necessary */
|
||||
if (value_type == IS_CONST) {
|
||||
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
|
||||
ZVAL_COPY_VALUE(&tmp, value);
|
||||
zval_copy_ctor_func(&tmp);
|
||||
value = &tmp;
|
||||
}
|
||||
} else if (value_type != IS_TMP_VAR &&
|
||||
Z_REFCOUNTED_P(value)) {
|
||||
Z_ADDREF_P(value);
|
||||
}
|
||||
|
||||
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC);
|
||||
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
zval_ptr_dtor(value);
|
||||
if (value_type == IS_VAR) {
|
||||
FREE_OP(free_value);
|
||||
}
|
||||
}
|
||||
|
||||
static void zend_binary_assign_op_obj_dim(zval *object, zval *property, zval *value, zval *retval, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC) TSRMLS_DC)
|
||||
{
|
||||
zval *z;
|
||||
zval rv;
|
||||
|
||||
if (Z_OBJ_HT_P(object)->read_dimension &&
|
||||
(z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv TSRMLS_CC)) != NULL) {
|
||||
|
||||
if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {
|
||||
zval rv;
|
||||
zval *value = Z_OBJ_HT_P(z)->get(z, &rv TSRMLS_CC);
|
||||
|
||||
if (Z_REFCOUNT_P(z) == 0) {
|
||||
zend_objects_store_del(Z_OBJ_P(z) TSRMLS_CC);
|
||||
}
|
||||
ZVAL_COPY_VALUE(z, value);
|
||||
}
|
||||
ZVAL_DEREF(z);
|
||||
SEPARATE_ZVAL_NOREF(z);
|
||||
binary_op(z, z, value TSRMLS_CC);
|
||||
Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC);
|
||||
if (retval) {
|
||||
ZVAL_COPY(retval, z);
|
||||
}
|
||||
zval_ptr_dtor(z);
|
||||
} else {
|
||||
zend_error(E_WARNING, "Attempt to assign property of non-object");
|
||||
if (retval) {
|
||||
ZVAL_NULL(retval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result TSRMLS_DC)
|
||||
{
|
||||
zend_string *old_str;
|
||||
|
@ -1173,6 +1227,7 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
|
|||
{
|
||||
zval *retval;
|
||||
|
||||
try_again:
|
||||
if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
|
||||
SEPARATE_ARRAY(container);
|
||||
fetch_from_array:
|
||||
|
@ -1234,7 +1289,7 @@ convert_to_array:
|
|||
ZVAL_INDIRECT(result, &EG(error_zval));
|
||||
}
|
||||
}
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_NULL)) {
|
||||
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
|
||||
if (UNEXPECTED(container == &EG(error_zval))) {
|
||||
ZVAL_INDIRECT(result, &EG(error_zval));
|
||||
} else if (type != BP_VAR_UNSET) {
|
||||
|
@ -1243,11 +1298,10 @@ convert_to_array:
|
|||
/* for read-mode only */
|
||||
ZVAL_NULL(result);
|
||||
}
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
|
||||
container = Z_REFVAL_P(container);
|
||||
goto try_again;
|
||||
} else {
|
||||
if (type != BP_VAR_UNSET &&
|
||||
Z_TYPE_P(container) == IS_FALSE) {
|
||||
goto convert_to_array;
|
||||
}
|
||||
if (type == BP_VAR_UNSET) {
|
||||
zend_error(E_WARNING, "Cannot unset offset in a non-array variable");
|
||||
ZVAL_NULL(result);
|
||||
|
@ -1277,13 +1331,14 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
|
|||
{
|
||||
zval *retval;
|
||||
|
||||
try_again:
|
||||
if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
|
||||
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
|
||||
ZVAL_COPY(result, retval);
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
|
||||
zend_long offset;
|
||||
|
||||
try_again:
|
||||
try_string_offset:
|
||||
if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
|
||||
switch(Z_TYPE_P(dim)) {
|
||||
/* case IS_LONG: */
|
||||
|
@ -1305,7 +1360,7 @@ try_again:
|
|||
break;
|
||||
case IS_REFERENCE:
|
||||
dim = Z_REFVAL_P(dim);
|
||||
goto try_again;
|
||||
goto try_string_offset;
|
||||
default:
|
||||
zend_error(E_WARNING, "Illegal offset type");
|
||||
break;
|
||||
|
@ -1345,6 +1400,9 @@ try_again:
|
|||
ZVAL_NULL(result);
|
||||
}
|
||||
}
|
||||
} else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
|
||||
container = Z_REFVAL_P(container);
|
||||
goto try_again;
|
||||
} else {
|
||||
ZVAL_NULL(result);
|
||||
}
|
||||
|
@ -1367,19 +1425,24 @@ ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval *
|
|||
|
||||
static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type TSRMLS_DC)
|
||||
{
|
||||
if (container_op_type != IS_UNUSED) {
|
||||
ZVAL_DEREF(container);
|
||||
if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
|
||||
if (UNEXPECTED(container == &EG(error_zval))) {
|
||||
if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
|
||||
do {
|
||||
if (container_op_type != IS_VAR && UNEXPECTED(container == &EG(error_zval))) {
|
||||
ZVAL_INDIRECT(result, &EG(error_zval));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Z_ISREF_P(container)) {
|
||||
container = Z_REFVAL_P(container);
|
||||
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* this should modify object only if it's empty */
|
||||
if (type != BP_VAR_UNSET &&
|
||||
EXPECTED((Z_TYPE_P(container) == IS_NULL ||
|
||||
Z_TYPE_P(container) == IS_FALSE ||
|
||||
(Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0)))) {
|
||||
EXPECTED(Z_TYPE_P(container) <= IS_FALSE ||
|
||||
(Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0))) {
|
||||
zval_ptr_dtor_nogc(container);
|
||||
object_init(container);
|
||||
} else {
|
||||
|
@ -1387,7 +1450,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
|
|||
ZVAL_INDIRECT(result, &EG(error_zval));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
if (prop_op_type == IS_CONST &&
|
||||
EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) {
|
||||
|
@ -1877,7 +1940,7 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
|
|||
}
|
||||
|
||||
ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) {
|
||||
return get_zval_ptr(op_type, node, execute_data, should_free, type);
|
||||
return get_zval_ptr(op_type, *node, execute_data, should_free, type);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -66,6 +66,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
|
|||
%left T_LOGICAL_AND
|
||||
%right T_PRINT
|
||||
%right T_YIELD
|
||||
%right T_DOUBLE_ARROW
|
||||
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL
|
||||
%left '?' ':'
|
||||
%right T_COALESCE
|
||||
|
@ -89,7 +90,6 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
|
|||
%left T_ELSE
|
||||
%left T_ENDIF
|
||||
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
|
||||
%right T_DOUBLE_ARROW
|
||||
|
||||
%token <ast> T_LNUMBER "integer number (T_LNUMBER)"
|
||||
%token <ast> T_DNUMBER "floating-point number (T_DNUMBER)"
|
||||
|
|
|
@ -102,6 +102,11 @@ typedef union _zend_value {
|
|||
void *ptr;
|
||||
zend_class_entry *ce;
|
||||
zend_function *func;
|
||||
struct {
|
||||
ZEND_ENDIAN_LOHI(
|
||||
uint32_t w1,
|
||||
uint32_t w2)
|
||||
} ww;
|
||||
} zend_value;
|
||||
|
||||
struct _zval_struct {
|
||||
|
@ -695,30 +700,64 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
|
|||
return --GC_REFCOUNT(Z_COUNTED_P(pz));
|
||||
}
|
||||
|
||||
#if SIZEOF_ZEND_LONG == 4
|
||||
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
|
||||
do { \
|
||||
uint32_t _w2; \
|
||||
gc = v->value.counted; \
|
||||
_w2 = v->value.ww.w2; \
|
||||
t = Z_TYPE_INFO_P(v); \
|
||||
z->value.counted = gc; \
|
||||
z->value.ww.w2 = _w2; \
|
||||
Z_TYPE_INFO_P(z) = t; \
|
||||
} while (0)
|
||||
#elif SIZEOF_ZEND_LONG == 8
|
||||
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
|
||||
do { \
|
||||
gc = v->value.counted; \
|
||||
t = Z_TYPE_INFO_P(v); \
|
||||
z->value.counted = gc; \
|
||||
Z_TYPE_INFO_P(z) = t; \
|
||||
} while (0)
|
||||
#else
|
||||
# error "Unknbown SIZEOF_ZEND_LONG"
|
||||
#endif
|
||||
|
||||
#define ZVAL_COPY_VALUE(z, v) \
|
||||
do { \
|
||||
zval *_z1 = (z); \
|
||||
const zval *_z2 = (v); \
|
||||
(_z1)->value = (_z2)->value; \
|
||||
Z_TYPE_INFO_P(_z1) = Z_TYPE_INFO_P(_z2); \
|
||||
zend_refcounted *_gc; \
|
||||
uint32_t _t; \
|
||||
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
||||
} while (0)
|
||||
|
||||
#define ZVAL_COPY(z, v) \
|
||||
do { \
|
||||
zval *__z1 = (z); \
|
||||
const zval *__z2 = (v); \
|
||||
ZVAL_COPY_VALUE(__z1, __z2); \
|
||||
if (Z_OPT_REFCOUNTED_P(__z1)) { \
|
||||
Z_ADDREF_P(__z1); \
|
||||
zval *_z1 = (z); \
|
||||
const zval *_z2 = (v); \
|
||||
zend_refcounted *_gc; \
|
||||
uint32_t _t; \
|
||||
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
||||
if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
||||
GC_REFCOUNT(_gc)++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ZVAL_DUP(z, v) \
|
||||
do { \
|
||||
zval *__z1 = (z); \
|
||||
const zval *__z2 = (v); \
|
||||
ZVAL_COPY_VALUE(__z1, __z2); \
|
||||
zval_opt_copy_ctor(__z1); \
|
||||
zval *_z1 = (z); \
|
||||
const zval *_z2 = (v); \
|
||||
zend_refcounted *_gc; \
|
||||
uint32_t _t; \
|
||||
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
||||
if ((_t & ((IS_TYPE_REFCOUNTED|IS_TYPE_IMMUTABLE) << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
||||
if ((_t & ((IS_TYPE_COPYABLE|IS_TYPE_IMMUTABLE) << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
||||
_zval_copy_ctor_func(_z1 ZEND_FILE_LINE_CC); \
|
||||
} else { \
|
||||
GC_REFCOUNT(_gc)++; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ZVAL_DEREF(z) do { \
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -134,7 +134,7 @@ $op2_free = array(
|
|||
);
|
||||
|
||||
$op1_get_zval_ptr = array(
|
||||
"ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_zval_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
|
||||
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "opline->op1.zv",
|
||||
|
@ -144,7 +144,7 @@ $op1_get_zval_ptr = array(
|
|||
);
|
||||
|
||||
$op2_get_zval_ptr = array(
|
||||
"ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_zval_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
|
||||
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "opline->op2.zv",
|
||||
|
@ -154,7 +154,7 @@ $op2_get_zval_ptr = array(
|
|||
);
|
||||
|
||||
$op1_get_zval_ptr_ptr = array(
|
||||
"ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_zval_ptr_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -164,7 +164,7 @@ $op1_get_zval_ptr_ptr = array(
|
|||
);
|
||||
|
||||
$op2_get_zval_ptr_ptr = array(
|
||||
"ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_zval_ptr_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -174,7 +174,7 @@ $op2_get_zval_ptr_ptr = array(
|
|||
);
|
||||
|
||||
$op1_get_zval_ptr_deref = array(
|
||||
"ANY" => "get_zval_ptr_deref(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_zval_ptr_deref(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
|
||||
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "opline->op1.zv",
|
||||
|
@ -184,7 +184,7 @@ $op1_get_zval_ptr_deref = array(
|
|||
);
|
||||
|
||||
$op2_get_zval_ptr_deref = array(
|
||||
"ANY" => "get_zval_ptr_deref(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_zval_ptr_deref(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
|
||||
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "opline->op2.zv",
|
||||
|
@ -194,7 +194,7 @@ $op2_get_zval_ptr_deref = array(
|
|||
);
|
||||
|
||||
$op1_get_zval_ptr_ptr_undef = array(
|
||||
"ANY" => "get_zval_ptr_ptr_undef(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_zval_ptr_ptr_undef(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -204,7 +204,7 @@ $op1_get_zval_ptr_ptr_undef = array(
|
|||
);
|
||||
|
||||
$op2_get_zval_ptr_ptr_undef = array(
|
||||
"ANY" => "get_zval_ptr_ptr_undef(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_zval_ptr_ptr_undef(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -214,7 +214,7 @@ $op2_get_zval_ptr_ptr_undef = array(
|
|||
);
|
||||
|
||||
$op1_get_obj_zval_ptr = array(
|
||||
"ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
|
||||
"VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "opline->op1.zv",
|
||||
|
@ -224,7 +224,7 @@ $op1_get_obj_zval_ptr = array(
|
|||
);
|
||||
|
||||
$op2_get_obj_zval_ptr = array(
|
||||
"ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
|
||||
"VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "opline->op2.zv",
|
||||
|
@ -234,7 +234,7 @@ $op2_get_obj_zval_ptr = array(
|
|||
);
|
||||
|
||||
$op1_get_obj_zval_ptr_deref = array(
|
||||
"ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1)",
|
||||
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "opline->op1.zv",
|
||||
|
@ -244,7 +244,7 @@ $op1_get_obj_zval_ptr_deref = array(
|
|||
);
|
||||
|
||||
$op2_get_obj_zval_ptr_deref = array(
|
||||
"ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2)",
|
||||
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "opline->op2.zv",
|
||||
|
@ -254,7 +254,7 @@ $op2_get_obj_zval_ptr_deref = array(
|
|||
);
|
||||
|
||||
$op1_get_obj_zval_ptr_ptr = array(
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -264,7 +264,7 @@ $op1_get_obj_zval_ptr_ptr = array(
|
|||
);
|
||||
|
||||
$op2_get_obj_zval_ptr_ptr = array(
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \\1)",
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "NULL",
|
||||
|
@ -273,6 +273,26 @@ $op2_get_obj_zval_ptr_ptr = array(
|
|||
"TMPVAR" => "???",
|
||||
);
|
||||
|
||||
$op1_get_obj_zval_ptr_ptr_undef = array(
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, opline->op1, execute_data, &free_op1, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1)",
|
||||
"CONST" => "NULL",
|
||||
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
|
||||
"CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op1.var TSRMLS_CC)",
|
||||
"TMPVAR" => "???",
|
||||
);
|
||||
|
||||
$op2_get_obj_zval_ptr_ptr_undef = array(
|
||||
"ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, opline->op2, execute_data, &free_op2, \\1)",
|
||||
"TMP" => "NULL",
|
||||
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2)",
|
||||
"CONST" => "NULL",
|
||||
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data)",
|
||||
"CV" => "_get_zval_ptr_cv_undef_\\1(execute_data, opline->op2.var TSRMLS_CC)",
|
||||
"TMPVAR" => "???",
|
||||
);
|
||||
|
||||
$op1_free_op = array(
|
||||
"ANY" => "FREE_OP(free_op1)",
|
||||
"TMP" => "zval_ptr_dtor_nogc(free_op1)",
|
||||
|
@ -384,6 +404,7 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name) {
|
|||
$op1_get_obj_zval_ptr, $op2_get_obj_zval_ptr,
|
||||
$op1_get_obj_zval_ptr_deref, $op2_get_obj_zval_ptr_deref,
|
||||
$op1_get_obj_zval_ptr_ptr, $op2_get_obj_zval_ptr_ptr,
|
||||
$op1_get_obj_zval_ptr_ptr_undef, $op2_get_obj_zval_ptr_ptr_undef,
|
||||
$op1_free, $op2_free,
|
||||
$op1_free_op, $op2_free_op, $op1_free_op_if_var, $op2_free_op_if_var,
|
||||
$op1_free_op_var_ptr, $op2_free_op_var_ptr, $prefix;
|
||||
|
@ -409,6 +430,8 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name) {
|
|||
"/GET_OP2_OBJ_ZVAL_PTR_DEREF\(([^)]*)\)/",
|
||||
"/GET_OP1_OBJ_ZVAL_PTR_PTR\(([^)]*)\)/",
|
||||
"/GET_OP2_OBJ_ZVAL_PTR_PTR\(([^)]*)\)/",
|
||||
"/GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF\(([^)]*)\)/",
|
||||
"/GET_OP2_OBJ_ZVAL_PTR_PTR_UNDEF\(([^)]*)\)/",
|
||||
"/FREE_OP1\(\)/",
|
||||
"/FREE_OP2\(\)/",
|
||||
"/FREE_OP1_IF_VAR\(\)/",
|
||||
|
@ -445,6 +468,8 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name) {
|
|||
$op2_get_obj_zval_ptr_deref[$op2],
|
||||
$op1_get_obj_zval_ptr_ptr[$op1],
|
||||
$op2_get_obj_zval_ptr_ptr[$op2],
|
||||
$op1_get_obj_zval_ptr_ptr_undef[$op1],
|
||||
$op2_get_obj_zval_ptr_ptr_undef[$op2],
|
||||
$op1_free_op[$op1],
|
||||
$op2_free_op[$op2],
|
||||
$op1_free_op_if_var[$op1],
|
||||
|
|
|
@ -23,9 +23,21 @@
|
|||
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
|
||||
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
|
||||
|
||||
static timelib_sll positive_mod(timelib_sll x, timelib_sll y)
|
||||
{
|
||||
timelib_sll tmp;
|
||||
|
||||
tmp = x % y;
|
||||
if (tmp < 0) {
|
||||
tmp += y;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static timelib_sll century_value(timelib_sll j)
|
||||
{
|
||||
return 6 - (j % 4) * 2;
|
||||
return 6 - positive_mod(j, 4) * 2;
|
||||
}
|
||||
|
||||
static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_sll d, int iso)
|
||||
|
@ -36,9 +48,9 @@ static timelib_sll timelib_day_of_week_ex(timelib_sll y, timelib_sll m, timelib_
|
|||
* Julian calendar. We just return the 'wrong' day of week to be
|
||||
* consistent. */
|
||||
c1 = century_value(y / 100);
|
||||
y1 = (y % 100);
|
||||
y1 = positive_mod(y, 100);
|
||||
m1 = timelib_is_leap(y) ? m_table_leap[m] : m_table_common[m];
|
||||
dow = (c1 + y1 + m1 + (y1 / 4) + d) % 7;
|
||||
dow = positive_mod((c1 + y1 + m1 + (y1 / 4) + d), 7);
|
||||
if (iso) {
|
||||
if (dow == 0) {
|
||||
dow = 7;
|
||||
|
|
|
@ -145,7 +145,7 @@ object(DateTime)#%d (3) {
|
|||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-02-15 08:34:10.000000"
|
||||
string(28) "-12345-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
|
@ -165,7 +165,7 @@ object(DateTime)#%d (3) {
|
|||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-02-19 08:34:10.000000"
|
||||
string(27) "-0010-02-14 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
|
|
|
@ -10,7 +10,8 @@ var_dump($date->format('r'));
|
|||
$date->setDate(-2147483648, 1, 1);
|
||||
var_dump($date->format('r'));
|
||||
var_dump($date->format('c'));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(32) "Sat, 01 Jan -1500 00:00:00 +0000"
|
||||
string(42) "Unknown, 01 Jan -2147483648 00:00:00 +0000"
|
||||
string(32) "Fri, 01 Jan -1500 00:00:00 +0000"
|
||||
string(38) "Mon, 01 Jan -2147483648 00:00:00 +0000"
|
||||
string(32) "-2147483648-01-01T00:00:00+00:00"
|
||||
|
|
|
@ -145,7 +145,7 @@ object(DateTime)#%d (3) {
|
|||
-- int -12345 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(28) "-12345-02-15 08:34:10.000000"
|
||||
string(28) "-12345-02-11 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
|
@ -165,7 +165,7 @@ object(DateTime)#%d (3) {
|
|||
-- float -10.5 --
|
||||
object(DateTime)#%d (3) {
|
||||
["date"]=>
|
||||
string(27) "-0010-02-19 08:34:10.000000"
|
||||
string(27) "-0010-02-14 08:34:10.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
|
|
|
@ -61,7 +61,7 @@ array\(11\) {
|
|||
\["mday"\]=>
|
||||
int\((9|14|23)\)
|
||||
\["wday"\]=>
|
||||
int\((6|-4)\)
|
||||
int\(0\)
|
||||
\["mon"\]=>
|
||||
int\((10|12)\)
|
||||
\["year"\]=>
|
||||
|
@ -69,7 +69,7 @@ array\(11\) {
|
|||
\["yday"\]=>
|
||||
int\((282|347|295)\)
|
||||
\["weekday"\]=>
|
||||
string\((8|7)\) "(Saturday|Unknown)"
|
||||
string\(6\) "Sunday"
|
||||
\["month"\]=>
|
||||
string\((7|8)\) "(October|December)"
|
||||
\[0\]=>
|
||||
|
|
|
@ -87,7 +87,7 @@ array\(9\) {
|
|||
\[5\]=>
|
||||
int\((104|1|-3843)\)
|
||||
\[6\]=>
|
||||
int\((5|-5)\)
|
||||
int\(6\)
|
||||
\[7\]=>
|
||||
int\((281|346|294)\)
|
||||
\[8\]=>
|
||||
|
@ -107,7 +107,7 @@ array\(9\) {
|
|||
\["tm_year"\]=>
|
||||
int\((104|1|-3843)\)
|
||||
\["tm_wday"\]=>
|
||||
int\((5|-5)\)
|
||||
int\(6\)
|
||||
\["tm_yday"\]=>
|
||||
int\((281|346|294)\)
|
||||
\["tm_isdst"\]=>
|
||||
|
|
|
@ -11,7 +11,7 @@ if test "$PHP_FILEINFO" != "no"; then
|
|||
libmagic/cdf.c libmagic/cdf_time.c libmagic/compress.c \
|
||||
libmagic/encoding.c libmagic/fsmagic.c libmagic/funcs.c \
|
||||
libmagic/is_tar.c libmagic/magic.c libmagic/print.c \
|
||||
libmagic/readcdf.c libmagic/readelf.c libmagic/softmagic.c"
|
||||
libmagic/readcdf.c libmagic/softmagic.c"
|
||||
|
||||
AC_MSG_CHECKING([for strcasestr])
|
||||
AC_TRY_RUN([
|
||||
|
|
|
@ -8,7 +8,7 @@ if (PHP_FILEINFO != 'no') {
|
|||
cdf.c cdf_time.c compress.c \
|
||||
encoding.c fsmagic.c funcs.c \
|
||||
is_tar.c magic.c print.c \
|
||||
readcdf.c readelf.c softmagic.c";
|
||||
readcdf.c softmagic.c";
|
||||
|
||||
if (VCVERS < 1500) {
|
||||
ADD_FLAG('CFLAGS', '/Zm1000');
|
||||
|
|
|
@ -3038,341 +3038,6 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
|
|||
}
|
||||
if (NOTMIME(ms)) {
|
||||
if (str != NULL) {
|
||||
diff -u libmagic.orig/readelf.c libmagic/readelf.c
|
||||
--- libmagic.orig/readelf.c Tue Nov 5 16:44:01 2013
|
||||
+++ libmagic/readelf.c Sat Oct 25 11:42:59 2014
|
||||
@@ -42,14 +42,14 @@
|
||||
#include "magic.h"
|
||||
|
||||
#ifdef ELFCORE
|
||||
-private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
|
||||
- off_t, int *);
|
||||
+private int dophn_core(struct magic_set *, int, int, int, zend_off_t, int, size_t,
|
||||
+ zend_off_t, int *);
|
||||
#endif
|
||||
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
|
||||
- off_t, int *, int);
|
||||
+ zend_off_t, int *, int);
|
||||
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
|
||||
- off_t, int *, int, int);
|
||||
-private size_t donote(struct magic_set *, void *, size_t, size_t, int,
|
||||
+ zend_off_t, int *, int);
|
||||
+private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
|
||||
int, size_t, int *);
|
||||
|
||||
#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
|
||||
@@ -127,7 +127,13 @@
|
||||
|
||||
#define elf_getu16(swap, value) getu16(swap, value)
|
||||
#define elf_getu32(swap, value) getu32(swap, value)
|
||||
-#define elf_getu64(swap, value) getu64(swap, value)
|
||||
+#ifdef USE_ARRAY_FOR_64BIT_TYPES
|
||||
+# define elf_getu64(swap, array) \
|
||||
+ ((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 : elf_getu32(swap, array[0])) + \
|
||||
+ (swap ? elf_getu32(swap, array[1]) : ((uint64_t)elf_getu32(swap, array[1]) << 32)))
|
||||
+#else
|
||||
+# define elf_getu64(swap, value) getu64(swap, value)
|
||||
+#endif
|
||||
|
||||
#define xsh_addr (clazz == ELFCLASS32 \
|
||||
? (void *)&sh32 \
|
||||
@@ -138,7 +144,7 @@
|
||||
#define xsh_size (size_t)(clazz == ELFCLASS32 \
|
||||
? elf_getu32(swap, sh32.sh_size) \
|
||||
: elf_getu64(swap, sh64.sh_size))
|
||||
-#define xsh_offset (off_t)(clazz == ELFCLASS32 \
|
||||
+#define xsh_offset (zend_off_t)(clazz == ELFCLASS32 \
|
||||
? elf_getu32(swap, sh32.sh_offset) \
|
||||
: elf_getu64(swap, sh64.sh_offset))
|
||||
#define xsh_type (clazz == ELFCLASS32 \
|
||||
@@ -156,13 +162,13 @@
|
||||
#define xph_type (clazz == ELFCLASS32 \
|
||||
? elf_getu32(swap, ph32.p_type) \
|
||||
: elf_getu32(swap, ph64.p_type))
|
||||
-#define xph_offset (off_t)(clazz == ELFCLASS32 \
|
||||
+#define xph_offset (zend_off_t)(clazz == ELFCLASS32 \
|
||||
? elf_getu32(swap, ph32.p_offset) \
|
||||
: elf_getu64(swap, ph64.p_offset))
|
||||
#define xph_align (size_t)((clazz == ELFCLASS32 \
|
||||
- ? (off_t) (ph32.p_align ? \
|
||||
+ ? (zend_off_t) (ph32.p_align ? \
|
||||
elf_getu32(swap, ph32.p_align) : 4) \
|
||||
- : (off_t) (ph64.p_align ? \
|
||||
+ : (zend_off_t) (ph64.p_align ? \
|
||||
elf_getu64(swap, ph64.p_align) : 4)))
|
||||
#define xph_filesz (size_t)((clazz == ELFCLASS32 \
|
||||
? elf_getu32(swap, ph32.p_filesz) \
|
||||
@@ -287,12 +293,12 @@
|
||||
#define FLAGS_IS_CORE 0x10
|
||||
|
||||
private int
|
||||
-dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
- int num, size_t size, off_t fsize, int *flags)
|
||||
+dophn_core(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
|
||||
+ int num, size_t size, zend_off_t fsize, int *flags)
|
||||
{
|
||||
Elf32_Phdr ph32;
|
||||
Elf64_Phdr ph64;
|
||||
- size_t offset, len;
|
||||
+ size_t offset;
|
||||
unsigned char nbuf[BUFSIZ];
|
||||
ssize_t bufsize;
|
||||
|
||||
@@ -306,7 +312,11 @@
|
||||
* Loop through all the program headers.
|
||||
*/
|
||||
for ( ; num; num--) {
|
||||
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
|
||||
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
|
||||
+ file_badseek(ms);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
}
|
||||
@@ -324,8 +334,13 @@
|
||||
* This is a PT_NOTE section; loop through all the notes
|
||||
* in the section.
|
||||
*/
|
||||
- len = xph_filesz < sizeof(nbuf) ? xph_filesz : sizeof(nbuf);
|
||||
- if ((bufsize = pread(fd, nbuf, len, xph_offset)) == -1) {
|
||||
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) {
|
||||
+ file_badseek(ms);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bufsize = FINFO_READ_FUNC(fd, nbuf,
|
||||
+ ((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf)));
|
||||
+ if (bufsize == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
}
|
||||
@@ -477,6 +492,13 @@
|
||||
uint32_t namesz, descsz;
|
||||
unsigned char *nbuf = CAST(unsigned char *, vbuf);
|
||||
|
||||
+ if (xnh_sizeof + offset > size) {
|
||||
+ /*
|
||||
+ * We're out of note headers.
|
||||
+ */
|
||||
+ return xnh_sizeof + offset;
|
||||
+ }
|
||||
+
|
||||
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
|
||||
offset += xnh_sizeof;
|
||||
|
||||
@@ -902,7 +924,7 @@
|
||||
Elf64_Shdr sh64;
|
||||
int stripped = 1;
|
||||
void *nbuf;
|
||||
- off_t noff, coff, name_off;
|
||||
+ zend_off_t noff, coff, name_off;
|
||||
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */
|
||||
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */
|
||||
char name[50];
|
||||
@@ -913,24 +935,12 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
- /* Read offset of name section to be able to read section names later */
|
||||
- if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) == -1) {
|
||||
- file_badread(ms);
|
||||
- return -1;
|
||||
- }
|
||||
- name_off = xsh_offset;
|
||||
-
|
||||
for ( ; num; num--) {
|
||||
- /* Read the name of this section. */
|
||||
- if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) {
|
||||
- file_badread(ms);
|
||||
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
|
||||
+ file_badseek(ms);
|
||||
return -1;
|
||||
}
|
||||
- name[sizeof(name) - 1] = '\0';
|
||||
- if (strcmp(name, ".debug_info") == 0)
|
||||
- stripped = 0;
|
||||
-
|
||||
- if (pread(fd, xsh_addr, xsh_sizeof, off) == -1) {
|
||||
+ if (FINFO_READ_FUNC(fd, xsh_addr, xsh_sizeof) == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
}
|
||||
@@ -955,41 +965,35 @@
|
||||
/* Things we can determine when we seek */
|
||||
switch (xsh_type) {
|
||||
case SHT_NOTE:
|
||||
- if ((nbuf = malloc(xsh_size)) == NULL) {
|
||||
- file_error(ms, errno, "Cannot allocate memory"
|
||||
- " for note");
|
||||
+ nbuf = emalloc((size_t)xsh_size);
|
||||
+ if ((noff = FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET)) ==
|
||||
+ (zend_off_t)-1) {
|
||||
+ file_badread(ms);
|
||||
+ efree(nbuf);
|
||||
return -1;
|
||||
}
|
||||
- if (pread(fd, nbuf, xsh_size, xsh_offset) == -1) {
|
||||
+ if (FINFO_READ_FUNC(fd, nbuf, (size_t)xsh_size) !=
|
||||
+ (ssize_t)xsh_size) {
|
||||
file_badread(ms);
|
||||
- free(nbuf);
|
||||
+ efree(nbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
noff = 0;
|
||||
for (;;) {
|
||||
- if (noff >= (off_t)xsh_size)
|
||||
+ if (noff >= (zend_off_t)xsh_size)
|
||||
break;
|
||||
noff = donote(ms, nbuf, (size_t)noff,
|
||||
- xsh_size, clazz, swap, 4, flags);
|
||||
+ (size_t)xsh_size, clazz, swap, 4,
|
||||
+ flags);
|
||||
if (noff == 0)
|
||||
break;
|
||||
}
|
||||
- free(nbuf);
|
||||
+ efree(nbuf);
|
||||
break;
|
||||
case SHT_SUNW_cap:
|
||||
- switch (mach) {
|
||||
- case EM_SPARC:
|
||||
- case EM_SPARCV9:
|
||||
- case EM_IA_64:
|
||||
- case EM_386:
|
||||
- case EM_AMD64:
|
||||
- break;
|
||||
- default:
|
||||
- goto skip;
|
||||
- }
|
||||
-
|
||||
- if (lseek(fd, xsh_offset, SEEK_SET) == (off_t)-1) {
|
||||
+ if (FINFO_LSEEK_FUNC(fd, (zend_off_t)xsh_offset, SEEK_SET) ==
|
||||
+ (zend_off_t)-1) {
|
||||
file_badseek(ms);
|
||||
return -1;
|
||||
}
|
||||
@@ -999,9 +1003,9 @@
|
||||
Elf64_Cap cap64;
|
||||
char cbuf[/*CONSTCOND*/
|
||||
MAX(sizeof cap32, sizeof cap64)];
|
||||
- if ((coff += xcap_sizeof) > (off_t)xsh_size)
|
||||
+ if ((coff += xcap_sizeof) > (zend_off_t)xsh_size)
|
||||
break;
|
||||
- if (read(fd, cbuf, (size_t)xcap_sizeof) !=
|
||||
+ if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) !=
|
||||
(ssize_t)xcap_sizeof) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
@@ -1027,13 +1031,12 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
- /*FALLTHROUGH*/
|
||||
- skip:
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-
|
||||
if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
|
||||
return -1;
|
||||
if (cap_hw1) {
|
||||
@@ -1103,8 +1106,8 @@
|
||||
* otherwise it's statically linked.
|
||||
*/
|
||||
private int
|
||||
-dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
- int num, size_t size, off_t fsize, int *flags, int sh_num)
|
||||
+dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, zend_off_t off,
|
||||
+ int num, size_t size, zend_off_t fsize, int *flags, int sh_num)
|
||||
{
|
||||
Elf32_Phdr ph32;
|
||||
Elf64_Phdr ph64;
|
||||
@@ -1112,7 +1115,7 @@
|
||||
const char *shared_libraries = "";
|
||||
unsigned char nbuf[BUFSIZ];
|
||||
ssize_t bufsize;
|
||||
- size_t offset, align, len;
|
||||
+ size_t offset, align;
|
||||
|
||||
if (size != xph_sizeof) {
|
||||
if (file_printf(ms, ", corrupted program header size") == -1)
|
||||
@@ -1121,8 +1124,13 @@
|
||||
}
|
||||
|
||||
for ( ; num; num--) {
|
||||
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) {
|
||||
- file_badread(ms);
|
||||
+ if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (zend_off_t)-1) {
|
||||
+ file_badseek(ms);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
|
||||
+ file_badread(ms);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1160,9 +1168,12 @@
|
||||
* This is a PT_NOTE section; loop through all the notes
|
||||
* in the section.
|
||||
*/
|
||||
- len = xph_filesz < sizeof(nbuf) ? xph_filesz
|
||||
- : sizeof(nbuf);
|
||||
- bufsize = pread(fd, nbuf, len, xph_offset);
|
||||
+ if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (zend_off_t)-1) {
|
||||
+ file_badseek(ms);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bufsize = FINFO_READ_FUNC(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ?
|
||||
+ xph_filesz : sizeof(nbuf)));
|
||||
if (bufsize == -1) {
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
@@ -1200,7 +1211,7 @@
|
||||
int clazz;
|
||||
int swap;
|
||||
struct stat st;
|
||||
- off_t fsize;
|
||||
+ zend_off_t fsize;
|
||||
int flags = 0;
|
||||
Elf32_Ehdr elf32hdr;
|
||||
Elf64_Ehdr elf64hdr;
|
||||
@@ -1223,7 +1234,7 @@
|
||||
/*
|
||||
* If we cannot seek, it must be a pipe, socket or fifo.
|
||||
*/
|
||||
- if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
|
||||
+ if((FINFO_LSEEK_FUNC(fd, (zend_off_t)0, SEEK_SET) == (zend_off_t)-1) && (errno == ESPIPE))
|
||||
fd = file_pipe2file(ms, fd, buf, nbytes);
|
||||
|
||||
if (fstat(fd, &st) == -1) {
|
||||
diff -u libmagic.orig/readelf.h libmagic/readelf.h
|
||||
--- libmagic.orig/readelf.h Tue Nov 5 16:41:56 2013
|
||||
+++ libmagic/readelf.h Wed Aug 27 12:35:45 2014
|
||||
@@ -44,9 +44,17 @@
|
||||
typedef uint32_t Elf32_Word;
|
||||
typedef uint8_t Elf32_Char;
|
||||
|
||||
+#if SIZEOF_LONG_LONG != 8
|
||||
+#define USE_ARRAY_FOR_64BIT_TYPES
|
||||
+typedef uint32_t Elf64_Addr[2];
|
||||
+typedef uint32_t Elf64_Off[2];
|
||||
+typedef uint32_t Elf64_Xword[2];
|
||||
+#else
|
||||
+#undef USE_ARRAY_FOR_64BIT_TYPES
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef uint64_t Elf64_Off;
|
||||
typedef uint64_t Elf64_Xword;
|
||||
+#endif
|
||||
typedef uint16_t Elf64_Half;
|
||||
typedef uint32_t Elf64_Word;
|
||||
typedef uint8_t Elf64_Char;
|
||||
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
|
||||
--- libmagic.orig/softmagic.c Thu Feb 13 00:20:53 2014
|
||||
+++ libmagic/softmagic.c Fri Sep 19 16:29:55 2014
|
||||
|
@ -3879,3 +3544,16 @@ diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
|
|||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
diff --git libmagic/file.h libmagic/file.h
|
||||
index 0a5c19c..2b2405f 100644
|
||||
--- libmagic/file.h
|
||||
+++ libmagic/file.h
|
||||
@@ -419,8 +419,6 @@ protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
|
||||
protected int file_replace(struct magic_set *, const char *, const char *);
|
||||
protected int file_printf(struct magic_set *, const char *, ...);
|
||||
protected int file_reset(struct magic_set *);
|
||||
-protected int file_tryelf(struct magic_set *, int, const unsigned char *,
|
||||
- size_t);
|
||||
protected int file_trycdf(struct magic_set *, int, const unsigned char *,
|
||||
size_t);
|
||||
#ifdef PHP_FILEINFO_UNCOMPRESS
|
||||
|
|
|
@ -419,8 +419,6 @@ protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
|
|||
protected int file_replace(struct magic_set *, const char *, const char *);
|
||||
protected int file_printf(struct magic_set *, const char *, ...);
|
||||
protected int file_reset(struct magic_set *);
|
||||
protected int file_tryelf(struct magic_set *, int, const unsigned char *,
|
||||
size_t);
|
||||
protected int file_trycdf(struct magic_set *, int, const unsigned char *,
|
||||
size_t);
|
||||
#ifdef PHP_FILEINFO_UNCOMPRESS
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,373 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice immediately at the beginning of the file, without modification,
|
||||
* this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
|
||||
*
|
||||
* Provide elf data structures for non-elf machines, allowing file
|
||||
* non-elf hosts to determine if an elf binary is stripped.
|
||||
* Note: cobbled from the linux header file, with modifications
|
||||
*/
|
||||
#ifndef __fake_elf_h__
|
||||
#define __fake_elf_h__
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef uint32_t Elf32_Addr;
|
||||
typedef uint32_t Elf32_Off;
|
||||
typedef uint16_t Elf32_Half;
|
||||
typedef uint32_t Elf32_Word;
|
||||
typedef uint8_t Elf32_Char;
|
||||
|
||||
#if SIZEOF_LONG_LONG != 8
|
||||
#define USE_ARRAY_FOR_64BIT_TYPES
|
||||
typedef uint32_t Elf64_Addr[2];
|
||||
typedef uint32_t Elf64_Off[2];
|
||||
typedef uint32_t Elf64_Xword[2];
|
||||
#else
|
||||
#undef USE_ARRAY_FOR_64BIT_TYPES
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef uint64_t Elf64_Off;
|
||||
typedef uint64_t Elf64_Xword;
|
||||
#endif
|
||||
typedef uint16_t Elf64_Half;
|
||||
typedef uint32_t Elf64_Word;
|
||||
typedef uint8_t Elf64_Char;
|
||||
|
||||
#define EI_NIDENT 16
|
||||
|
||||
typedef struct {
|
||||
Elf32_Char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry; /* Entry point */
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
} Elf32_Ehdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Char e_ident[EI_NIDENT];
|
||||
Elf64_Half e_type;
|
||||
Elf64_Half e_machine;
|
||||
Elf64_Word e_version;
|
||||
Elf64_Addr e_entry; /* Entry point */
|
||||
Elf64_Off e_phoff;
|
||||
Elf64_Off e_shoff;
|
||||
Elf64_Word e_flags;
|
||||
Elf64_Half e_ehsize;
|
||||
Elf64_Half e_phentsize;
|
||||
Elf64_Half e_phnum;
|
||||
Elf64_Half e_shentsize;
|
||||
Elf64_Half e_shnum;
|
||||
Elf64_Half e_shstrndx;
|
||||
} Elf64_Ehdr;
|
||||
|
||||
/* e_type */
|
||||
#define ET_REL 1
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
|
||||
/* e_machine (used only for SunOS 5.x hardware capabilities) */
|
||||
#define EM_SPARC 2
|
||||
#define EM_386 3
|
||||
#define EM_SPARC32PLUS 18
|
||||
#define EM_SPARCV9 43
|
||||
#define EM_IA_64 50
|
||||
#define EM_AMD64 62
|
||||
|
||||
/* sh_type */
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_DYNSYM 11
|
||||
#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */
|
||||
|
||||
/* elf type */
|
||||
#define ELFDATANONE 0 /* e_ident[EI_DATA] */
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
/* elf class */
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
|
||||
/* magic number */
|
||||
#define EI_MAG0 0 /* e_ident[] indexes */
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_PAD 7
|
||||
|
||||
#define ELFMAG0 0x7f /* EI_MAG */
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
#define ELFMAG "\177ELF"
|
||||
|
||||
#define OLFMAG1 'O'
|
||||
#define OLFMAG "\177OLF"
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word p_type;
|
||||
Elf64_Word p_flags;
|
||||
Elf64_Off p_offset;
|
||||
Elf64_Addr p_vaddr;
|
||||
Elf64_Addr p_paddr;
|
||||
Elf64_Xword p_filesz;
|
||||
Elf64_Xword p_memsz;
|
||||
Elf64_Xword p_align;
|
||||
} Elf64_Phdr;
|
||||
|
||||
#define PT_NULL 0 /* p_type */
|
||||
#define PT_LOAD 1
|
||||
#define PT_DYNAMIC 2
|
||||
#define PT_INTERP 3
|
||||
#define PT_NOTE 4
|
||||
#define PT_SHLIB 5
|
||||
#define PT_PHDR 6
|
||||
#define PT_NUM 7
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word sh_name;
|
||||
Elf32_Word sh_type;
|
||||
Elf32_Word sh_flags;
|
||||
Elf32_Addr sh_addr;
|
||||
Elf32_Off sh_offset;
|
||||
Elf32_Word sh_size;
|
||||
Elf32_Word sh_link;
|
||||
Elf32_Word sh_info;
|
||||
Elf32_Word sh_addralign;
|
||||
Elf32_Word sh_entsize;
|
||||
} Elf32_Shdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word sh_name;
|
||||
Elf64_Word sh_type;
|
||||
Elf64_Off sh_flags;
|
||||
Elf64_Addr sh_addr;
|
||||
Elf64_Off sh_offset;
|
||||
Elf64_Off sh_size;
|
||||
Elf64_Word sh_link;
|
||||
Elf64_Word sh_info;
|
||||
Elf64_Off sh_addralign;
|
||||
Elf64_Off sh_entsize;
|
||||
} Elf64_Shdr;
|
||||
|
||||
#define NT_NETBSD_CORE_PROCINFO 1
|
||||
|
||||
/* Note header in a PT_NOTE section */
|
||||
typedef struct elf_note {
|
||||
Elf32_Word n_namesz; /* Name size */
|
||||
Elf32_Word n_descsz; /* Content size */
|
||||
Elf32_Word n_type; /* Content type */
|
||||
} Elf32_Nhdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word n_namesz;
|
||||
Elf64_Word n_descsz;
|
||||
Elf64_Word n_type;
|
||||
} Elf64_Nhdr;
|
||||
|
||||
/* Notes used in ET_CORE */
|
||||
#define NT_PRSTATUS 1
|
||||
#define NT_PRFPREG 2
|
||||
#define NT_PRPSINFO 3
|
||||
#define NT_PRXREG 4
|
||||
#define NT_TASKSTRUCT 4
|
||||
#define NT_PLATFORM 5
|
||||
#define NT_AUXV 6
|
||||
|
||||
/* Note types used in executables */
|
||||
/* NetBSD executables (name = "NetBSD") */
|
||||
#define NT_NETBSD_VERSION 1
|
||||
#define NT_NETBSD_EMULATION 2
|
||||
#define NT_FREEBSD_VERSION 1
|
||||
#define NT_OPENBSD_VERSION 1
|
||||
#define NT_DRAGONFLY_VERSION 1
|
||||
/*
|
||||
* GNU executables (name = "GNU")
|
||||
* word[0]: GNU OS tags
|
||||
* word[1]: major version
|
||||
* word[2]: minor version
|
||||
* word[3]: tiny version
|
||||
*/
|
||||
#define NT_GNU_VERSION 1
|
||||
|
||||
/* GNU OS tags */
|
||||
#define GNU_OS_LINUX 0
|
||||
#define GNU_OS_HURD 1
|
||||
#define GNU_OS_SOLARIS 2
|
||||
#define GNU_OS_KFREEBSD 3
|
||||
#define GNU_OS_KNETBSD 4
|
||||
|
||||
/*
|
||||
* GNU Hardware capability information
|
||||
* word[0]: Number of entries
|
||||
* word[1]: Bitmask of enabled entries
|
||||
* Followed by a byte id, and a NUL terminated string per entry
|
||||
*/
|
||||
#define NT_GNU_HWCAP 2
|
||||
|
||||
/*
|
||||
* GNU Build ID generated by ld
|
||||
* 160 bit SHA1 [default]
|
||||
* 128 bit md5 or uuid
|
||||
*/
|
||||
#define NT_GNU_BUILD_ID 3
|
||||
|
||||
/*
|
||||
* NetBSD-specific note type: PaX.
|
||||
* There should be 1 NOTE per executable.
|
||||
* name: PaX\0
|
||||
* namesz: 4
|
||||
* desc:
|
||||
* word[0]: capability bitmask
|
||||
* descsz: 4
|
||||
*/
|
||||
#define NT_NETBSD_PAX 3
|
||||
#define NT_NETBSD_PAX_MPROTECT 0x01 /* Force enable Mprotect */
|
||||
#define NT_NETBSD_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */
|
||||
#define NT_NETBSD_PAX_GUARD 0x04 /* Force enable Segvguard */
|
||||
#define NT_NETBSD_PAX_NOGUARD 0x08 /* Force disable Servguard */
|
||||
#define NT_NETBSD_PAX_ASLR 0x10 /* Force enable ASLR */
|
||||
#define NT_NETBSD_PAX_NOASLR 0x20 /* Force disable ASLR */
|
||||
|
||||
/*
|
||||
* NetBSD-specific note type: MACHINE_ARCH.
|
||||
* There should be 1 NOTE per executable.
|
||||
* name: NetBSD\0
|
||||
* namesz: 7
|
||||
* desc: string
|
||||
* descsz: variable
|
||||
*/
|
||||
#define NT_NETBSD_MARCH 5
|
||||
|
||||
/*
|
||||
* NetBSD-specific note type: COMPILER MODEL.
|
||||
* There should be 1 NOTE per executable.
|
||||
* name: NetBSD\0
|
||||
* namesz: 7
|
||||
* desc: string
|
||||
* descsz: variable
|
||||
*/
|
||||
#define NT_NETBSD_CMODEL 6
|
||||
|
||||
#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
|
||||
#define ELFSIZE ARCH_ELFSIZE
|
||||
#endif
|
||||
/* SunOS 5.x hardware/software capabilities */
|
||||
typedef struct {
|
||||
Elf32_Word c_tag;
|
||||
union {
|
||||
Elf32_Word c_val;
|
||||
Elf32_Addr c_ptr;
|
||||
} c_un;
|
||||
} Elf32_Cap;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Xword c_tag;
|
||||
union {
|
||||
Elf64_Xword c_val;
|
||||
Elf64_Addr c_ptr;
|
||||
} c_un;
|
||||
} Elf64_Cap;
|
||||
|
||||
/* SunOS 5.x hardware/software capability tags */
|
||||
#define CA_SUNW_NULL 0
|
||||
#define CA_SUNW_HW_1 1
|
||||
#define CA_SUNW_SF_1 2
|
||||
|
||||
/* SunOS 5.x software capabilities */
|
||||
#define SF1_SUNW_FPKNWN 0x01
|
||||
#define SF1_SUNW_FPUSED 0x02
|
||||
#define SF1_SUNW_MASK 0x03
|
||||
|
||||
/* SunOS 5.x hardware capabilities: sparc */
|
||||
#define AV_SPARC_MUL32 0x0001
|
||||
#define AV_SPARC_DIV32 0x0002
|
||||
#define AV_SPARC_FSMULD 0x0004
|
||||
#define AV_SPARC_V8PLUS 0x0008
|
||||
#define AV_SPARC_POPC 0x0010
|
||||
#define AV_SPARC_VIS 0x0020
|
||||
#define AV_SPARC_VIS2 0x0040
|
||||
#define AV_SPARC_ASI_BLK_INIT 0x0080
|
||||
#define AV_SPARC_FMAF 0x0100
|
||||
#define AV_SPARC_FJFMAU 0x4000
|
||||
#define AV_SPARC_IMA 0x8000
|
||||
|
||||
/* SunOS 5.x hardware capabilities: 386 */
|
||||
#define AV_386_FPU 0x00000001
|
||||
#define AV_386_TSC 0x00000002
|
||||
#define AV_386_CX8 0x00000004
|
||||
#define AV_386_SEP 0x00000008
|
||||
#define AV_386_AMD_SYSC 0x00000010
|
||||
#define AV_386_CMOV 0x00000020
|
||||
#define AV_386_MMX 0x00000040
|
||||
#define AV_386_AMD_MMX 0x00000080
|
||||
#define AV_386_AMD_3DNow 0x00000100
|
||||
#define AV_386_AMD_3DNowx 0x00000200
|
||||
#define AV_386_FXSR 0x00000400
|
||||
#define AV_386_SSE 0x00000800
|
||||
#define AV_386_SSE2 0x00001000
|
||||
#define AV_386_PAUSE 0x00002000
|
||||
#define AV_386_SSE3 0x00004000
|
||||
#define AV_386_MON 0x00008000
|
||||
#define AV_386_CX16 0x00010000
|
||||
#define AV_386_AHF 0x00020000
|
||||
#define AV_386_TSCP 0x00040000
|
||||
#define AV_386_AMD_SSE4A 0x00080000
|
||||
#define AV_386_POPCNT 0x00100000
|
||||
#define AV_386_AMD_LZCNT 0x00200000
|
||||
#define AV_386_SSSE3 0x00400000
|
||||
#define AV_386_SSE4_1 0x00800000
|
||||
#define AV_386_SSE4_2 0x01000000
|
||||
|
||||
#endif
|
|
@ -579,8 +579,11 @@ PHP_FUNCTION(mcrypt_generic_init)
|
|||
|
||||
if (iv_len != iv_size) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Iv size incorrect; supplied length: %d, needed: %d", iv_len, iv_size);
|
||||
if (iv_len > iv_size) {
|
||||
iv_len = iv_size;
|
||||
}
|
||||
}
|
||||
memcpy(iv_s, iv, iv_size);
|
||||
memcpy(iv_s, iv, iv_len);
|
||||
|
||||
mcrypt_generic_deinit(pm->td);
|
||||
result = mcrypt_generic_init(pm->td, key_s, key_size, iv_s);
|
||||
|
@ -601,8 +604,9 @@ PHP_FUNCTION(mcrypt_generic_init)
|
|||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
pm->init = 1;
|
||||
}
|
||||
pm->init = 1;
|
||||
RETVAL_LONG(result);
|
||||
|
||||
efree(iv_s);
|
||||
|
|
11
ext/standard/tests/serialize/bug68545.phpt
Normal file
11
ext/standard/tests/serialize/bug68545.phpt
Normal file
|
@ -0,0 +1,11 @@
|
|||
--TEST--
|
||||
Bug #68545 NULL pointer dereference in unserialize.c:var_push_dtor
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(unserialize('a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"b22";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";s:3:"bar";'));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Notice: unserialize(): Error at offset %d of %d bytes in %sbug68545.php on line %d
|
||||
bool(false)
|
||||
===DONE===
|
|
@ -1,4 +1,4 @@
|
|||
/* Generated by re2c 0.13.7.5 */
|
||||
/* Generated by re2c 0.13.5 */
|
||||
#line 1 "ext/standard/var_unserializer.re"
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
|
@ -66,7 +66,13 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval *rval)
|
|||
|
||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval)
|
||||
{
|
||||
var_dtor_entries *var_hash = (*var_hashx)->last_dtor;
|
||||
var_dtor_entries *var_hash;
|
||||
|
||||
if (!var_hashx || !*var_hashx) {
|
||||
return;
|
||||
}
|
||||
|
||||
var_hash = (*var_hashx)->last_dtor;
|
||||
#if VAR_ENTRIES_DBG
|
||||
fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
|
||||
#endif
|
||||
|
@ -253,7 +259,7 @@ static inline int unserialize_allowed_class(zend_string *class_name, HashTable *
|
|||
#define YYMARKER marker
|
||||
|
||||
|
||||
#line 261 "ext/standard/var_unserializer.re"
|
||||
#line 267 "ext/standard/var_unserializer.re"
|
||||
|
||||
|
||||
|
||||
|
@ -509,7 +515,7 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
|
|||
start = cursor;
|
||||
|
||||
|
||||
#line 513 "ext/standard/var_unserializer.c"
|
||||
#line 519 "ext/standard/var_unserializer.c"
|
||||
{
|
||||
YYCTYPE yych;
|
||||
static const unsigned char yybm[] = {
|
||||
|
@ -569,9 +575,9 @@ yy2:
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych == ':') goto yy95;
|
||||
yy3:
|
||||
#line 860 "ext/standard/var_unserializer.re"
|
||||
#line 866 "ext/standard/var_unserializer.re"
|
||||
{ return 0; }
|
||||
#line 575 "ext/standard/var_unserializer.c"
|
||||
#line 581 "ext/standard/var_unserializer.c"
|
||||
yy4:
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
if (yych == ':') goto yy89;
|
||||
|
@ -614,13 +620,13 @@ yy13:
|
|||
goto yy3;
|
||||
yy14:
|
||||
++YYCURSOR;
|
||||
#line 854 "ext/standard/var_unserializer.re"
|
||||
#line 860 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
/* this is the case where we have less data than planned */
|
||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
|
||||
return 0; /* not sure if it should be 0 or 1 here? */
|
||||
}
|
||||
#line 624 "ext/standard/var_unserializer.c"
|
||||
#line 630 "ext/standard/var_unserializer.c"
|
||||
yy16:
|
||||
yych = *++YYCURSOR;
|
||||
goto yy3;
|
||||
|
@ -646,12 +652,11 @@ yy20:
|
|||
if (yybm[0+yych] & 128) {
|
||||
goto yy20;
|
||||
}
|
||||
if (yych <= '/') goto yy18;
|
||||
if (yych >= ';') goto yy18;
|
||||
if (yych != ':') goto yy18;
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != '"') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 709 "ext/standard/var_unserializer.re"
|
||||
#line 715 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
size_t len, len2, len3, maxlen;
|
||||
zend_long elements;
|
||||
|
@ -796,7 +801,7 @@ yy20:
|
|||
|
||||
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
||||
}
|
||||
#line 800 "ext/standard/var_unserializer.c"
|
||||
#line 805 "ext/standard/var_unserializer.c"
|
||||
yy25:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
|
@ -821,7 +826,7 @@ yy27:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != '"') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 701 "ext/standard/var_unserializer.re"
|
||||
#line 707 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
|
||||
//??? INIT_PZVAL(rval);
|
||||
|
@ -829,7 +834,7 @@ yy27:
|
|||
return object_common2(UNSERIALIZE_PASSTHRU,
|
||||
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
||||
}
|
||||
#line 833 "ext/standard/var_unserializer.c"
|
||||
#line 838 "ext/standard/var_unserializer.c"
|
||||
yy32:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy33;
|
||||
|
@ -850,7 +855,7 @@ yy34:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != '{') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 680 "ext/standard/var_unserializer.re"
|
||||
#line 686 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
zend_long elements = parse_iv(start + 2);
|
||||
/* use iv() not uiv() in order to check data range */
|
||||
|
@ -871,7 +876,7 @@ yy34:
|
|||
|
||||
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
||||
}
|
||||
#line 875 "ext/standard/var_unserializer.c"
|
||||
#line 880 "ext/standard/var_unserializer.c"
|
||||
yy39:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy40;
|
||||
|
@ -892,7 +897,7 @@ yy41:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != '"') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 652 "ext/standard/var_unserializer.re"
|
||||
#line 658 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
size_t len, maxlen;
|
||||
zend_string *str;
|
||||
|
@ -920,7 +925,7 @@ yy41:
|
|||
ZVAL_STR(rval, str);
|
||||
return 1;
|
||||
}
|
||||
#line 924 "ext/standard/var_unserializer.c"
|
||||
#line 929 "ext/standard/var_unserializer.c"
|
||||
yy46:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy47;
|
||||
|
@ -941,7 +946,7 @@ yy48:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != '"') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 625 "ext/standard/var_unserializer.re"
|
||||
#line 631 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
size_t len, maxlen;
|
||||
char *str;
|
||||
|
@ -968,7 +973,7 @@ yy48:
|
|||
ZVAL_STRINGL(rval, str, len);
|
||||
return 1;
|
||||
}
|
||||
#line 972 "ext/standard/var_unserializer.c"
|
||||
#line 977 "ext/standard/var_unserializer.c"
|
||||
yy53:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') {
|
||||
|
@ -1056,7 +1061,7 @@ yy61:
|
|||
}
|
||||
yy63:
|
||||
++YYCURSOR;
|
||||
#line 616 "ext/standard/var_unserializer.re"
|
||||
#line 622 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
#if SIZEOF_ZEND_LONG == 4
|
||||
use_double:
|
||||
|
@ -1065,7 +1070,7 @@ use_double:
|
|||
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
|
||||
return 1;
|
||||
}
|
||||
#line 1069 "ext/standard/var_unserializer.c"
|
||||
#line 1074 "ext/standard/var_unserializer.c"
|
||||
yy65:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
|
@ -1124,7 +1129,7 @@ yy73:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != ';') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 600 "ext/standard/var_unserializer.re"
|
||||
#line 606 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
*p = YYCURSOR;
|
||||
|
||||
|
@ -1140,7 +1145,7 @@ yy73:
|
|||
|
||||
return 1;
|
||||
}
|
||||
#line 1144 "ext/standard/var_unserializer.c"
|
||||
#line 1149 "ext/standard/var_unserializer.c"
|
||||
yy76:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 'N') goto yy73;
|
||||
|
@ -1167,7 +1172,7 @@ yy79:
|
|||
if (yych <= '9') goto yy79;
|
||||
if (yych != ';') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 574 "ext/standard/var_unserializer.re"
|
||||
#line 580 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
#if SIZEOF_ZEND_LONG == 4
|
||||
int digits = YYCURSOR - start - 3;
|
||||
|
@ -1193,7 +1198,7 @@ yy79:
|
|||
ZVAL_LONG(rval, parse_iv(start + 2));
|
||||
return 1;
|
||||
}
|
||||
#line 1197 "ext/standard/var_unserializer.c"
|
||||
#line 1202 "ext/standard/var_unserializer.c"
|
||||
yy83:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy18;
|
||||
|
@ -1201,22 +1206,22 @@ yy83:
|
|||
yych = *++YYCURSOR;
|
||||
if (yych != ';') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 568 "ext/standard/var_unserializer.re"
|
||||
#line 574 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
*p = YYCURSOR;
|
||||
ZVAL_BOOL(rval, parse_iv(start + 2));
|
||||
return 1;
|
||||
}
|
||||
#line 1211 "ext/standard/var_unserializer.c"
|
||||
#line 1216 "ext/standard/var_unserializer.c"
|
||||
yy87:
|
||||
++YYCURSOR;
|
||||
#line 562 "ext/standard/var_unserializer.re"
|
||||
#line 568 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
*p = YYCURSOR;
|
||||
ZVAL_NULL(rval);
|
||||
return 1;
|
||||
}
|
||||
#line 1220 "ext/standard/var_unserializer.c"
|
||||
#line 1225 "ext/standard/var_unserializer.c"
|
||||
yy89:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
|
@ -1239,7 +1244,7 @@ yy91:
|
|||
if (yych <= '9') goto yy91;
|
||||
if (yych != ';') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 539 "ext/standard/var_unserializer.re"
|
||||
#line 545 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
zend_long id;
|
||||
|
||||
|
@ -1262,7 +1267,7 @@ yy91:
|
|||
|
||||
return 1;
|
||||
}
|
||||
#line 1266 "ext/standard/var_unserializer.c"
|
||||
#line 1271 "ext/standard/var_unserializer.c"
|
||||
yy95:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
|
@ -1285,7 +1290,7 @@ yy97:
|
|||
if (yych <= '9') goto yy97;
|
||||
if (yych != ';') goto yy18;
|
||||
++YYCURSOR;
|
||||
#line 517 "ext/standard/var_unserializer.re"
|
||||
#line 523 "ext/standard/var_unserializer.re"
|
||||
{
|
||||
zend_long id;
|
||||
|
||||
|
@ -1307,9 +1312,9 @@ yy97:
|
|||
|
||||
return 1;
|
||||
}
|
||||
#line 1311 "ext/standard/var_unserializer.c"
|
||||
#line 1316 "ext/standard/var_unserializer.c"
|
||||
}
|
||||
#line 862 "ext/standard/var_unserializer.re"
|
||||
#line 868 "ext/standard/var_unserializer.re"
|
||||
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -64,7 +64,13 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval *rval)
|
|||
|
||||
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval)
|
||||
{
|
||||
var_dtor_entries *var_hash = (*var_hashx)->last_dtor;
|
||||
var_dtor_entries *var_hash;
|
||||
|
||||
if (!var_hashx || !*var_hashx) {
|
||||
return;
|
||||
}
|
||||
|
||||
var_hash = (*var_hashx)->last_dtor;
|
||||
#if VAR_ENTRIES_DBG
|
||||
fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
|
||||
#endif
|
||||
|
|
|
@ -583,6 +583,9 @@ if test "$PHP_FPM" != "no"; then
|
|||
PHP_ARG_WITH(fpm-systemd,,
|
||||
[ --with-fpm-systemd Activate systemd integration], no, no)
|
||||
|
||||
PHP_ARG_WITH(fpm-acl,,
|
||||
[ --with-fpm-acl Use POSIX Access Control Lists], no, no)
|
||||
|
||||
if test "$PHP_FPM_SYSTEMD" != "no" ; then
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
|
@ -624,6 +627,17 @@ if test "$PHP_FPM" != "no"; then
|
|||
else
|
||||
php_fpm_systemd=simple
|
||||
fi
|
||||
|
||||
if test "$PHP_FPM_ACL" != "no" ; then
|
||||
AC_CHECK_HEADERS([sys/acl.h])
|
||||
AC_CHECK_LIB(acl, acl_free, [
|
||||
PHP_ADD_LIBRARY(acl)
|
||||
AC_DEFINE(HAVE_FPM_ACL, 1, [ POSIX Access Control List ])
|
||||
],[
|
||||
AC_MSG_ERROR(libacl required not found)
|
||||
])
|
||||
fi
|
||||
|
||||
PHP_SUBST_OLD(php_fpm_systemd)
|
||||
AC_DEFINE_UNQUOTED(PHP_FPM_SYSTEMD, "$php_fpm_systemd", [fpm systemd service type])
|
||||
|
||||
|
|
|
@ -123,6 +123,10 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = {
|
|||
{ "group", &fpm_conf_set_string, WPO(group) },
|
||||
{ "listen", &fpm_conf_set_string, WPO(listen_address) },
|
||||
{ "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
|
||||
#ifdef HAVE_FPM_ACL
|
||||
{ "listen.acl_users", &fpm_conf_set_string, WPO(listen_acl_users) },
|
||||
{ "listen.acl_groups", &fpm_conf_set_string, WPO(listen_acl_groups) },
|
||||
#endif
|
||||
{ "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
|
||||
{ "listen.group", &fpm_conf_set_string, WPO(listen_group) },
|
||||
{ "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
|
||||
|
@ -1602,6 +1606,10 @@ static void fpm_conf_dump() /* {{{ */
|
|||
zlog(ZLOG_NOTICE, "\tgroup = %s", STR2STR(wp->config->group));
|
||||
zlog(ZLOG_NOTICE, "\tlisten = %s", STR2STR(wp->config->listen_address));
|
||||
zlog(ZLOG_NOTICE, "\tlisten.backlog = %d", wp->config->listen_backlog);
|
||||
#ifdef HAVE_FPM_ACL
|
||||
zlog(ZLOG_NOTICE, "\tlisten.acl_users = %s", STR2STR(wp->config->listen_acl_users));
|
||||
zlog(ZLOG_NOTICE, "\tlisten.acl_groups = %s", STR2STR(wp->config->listen_acl_groups));
|
||||
#endif
|
||||
zlog(ZLOG_NOTICE, "\tlisten.owner = %s", STR2STR(wp->config->listen_owner));
|
||||
zlog(ZLOG_NOTICE, "\tlisten.group = %s", STR2STR(wp->config->listen_group));
|
||||
zlog(ZLOG_NOTICE, "\tlisten.mode = %s", STR2STR(wp->config->listen_mode));
|
||||
|
|
|
@ -58,6 +58,7 @@ struct fpm_worker_pool_config_s {
|
|||
char *group;
|
||||
char *listen_address;
|
||||
int listen_backlog;
|
||||
/* Using chown */
|
||||
char *listen_owner;
|
||||
char *listen_group;
|
||||
char *listen_mode;
|
||||
|
@ -91,6 +92,11 @@ struct fpm_worker_pool_config_s {
|
|||
#ifdef HAVE_APPARMOR
|
||||
char *apparmor_hat;
|
||||
#endif
|
||||
#ifdef HAVE_FPM_ACL
|
||||
/* Using Posix ACL */
|
||||
char *listen_acl_users;
|
||||
char *listen_acl_groups;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ini_value_parser_s {
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include <sys/apparmor.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_ACL_H
|
||||
#include <sys/acl.h>
|
||||
#endif
|
||||
|
||||
#include "fpm.h"
|
||||
#include "fpm_conf.h"
|
||||
#include "fpm_cleanup.h"
|
||||
|
@ -35,8 +39,12 @@ size_t fpm_pagesize;
|
|||
int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
struct fpm_worker_pool_config_s *c = wp->config;
|
||||
#ifdef HAVE_FPM_ACL
|
||||
int n;
|
||||
|
||||
/* uninitialized */
|
||||
wp->socket_acl = NULL;
|
||||
#endif
|
||||
wp->socket_uid = -1;
|
||||
wp->socket_gid = -1;
|
||||
wp->socket_mode = 0660;
|
||||
|
@ -45,6 +53,117 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (c->listen_mode && *c->listen_mode) {
|
||||
wp->socket_mode = strtoul(c->listen_mode, 0, 8);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FPM_ACL
|
||||
/* count the users and groups configured */
|
||||
n = 0;
|
||||
if (c->listen_acl_users && *c->listen_acl_users) {
|
||||
char *p;
|
||||
n++;
|
||||
for (p=strchr(c->listen_acl_users, ',') ; p ; p=strchr(p+1, ',')) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
if (c->listen_acl_groups && *c->listen_acl_groups) {
|
||||
char *p;
|
||||
n++;
|
||||
for (p=strchr(c->listen_acl_groups, ',') ; p ; p=strchr(p+1, ',')) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
/* if ACL configured */
|
||||
if (n) {
|
||||
acl_t acl;
|
||||
acl_entry_t entry;
|
||||
acl_permset_t perm;
|
||||
char *tmp, *p, *end;
|
||||
|
||||
acl = acl_init(n);
|
||||
if (!acl) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] cannot allocate ACL", wp->config->name);
|
||||
return -1;
|
||||
}
|
||||
/* Create USER ACL */
|
||||
if (c->listen_acl_users && *c->listen_acl_users) {
|
||||
struct passwd *pwd;
|
||||
|
||||
tmp = estrdup(c->listen_acl_users);
|
||||
for (p=tmp ; p ; p=end) {
|
||||
if ((end = strchr(p, ','))) {
|
||||
*end++ = 0;
|
||||
}
|
||||
pwd = getpwnam(p);
|
||||
if (pwd) {
|
||||
zlog(ZLOG_DEBUG, "[pool %s] user '%s' have uid=%d", wp->config->name, p, pwd->pw_uid);
|
||||
} else {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, p);
|
||||
acl_free(acl);
|
||||
efree(tmp);
|
||||
return -1;
|
||||
}
|
||||
if (0 > acl_create_entry(&acl, &entry) ||
|
||||
0 > acl_set_tag_type(entry, ACL_USER) ||
|
||||
0 > acl_set_qualifier(entry, &pwd->pw_uid) ||
|
||||
0 > acl_get_permset(entry, &perm) ||
|
||||
0 > acl_clear_perms (perm) ||
|
||||
0 > acl_add_perm (perm, ACL_READ) ||
|
||||
0 > acl_add_perm (perm, ACL_WRITE)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] cannot create ACL for user '%s'", wp->config->name, p);
|
||||
acl_free(acl);
|
||||
efree(tmp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
efree(tmp);
|
||||
}
|
||||
/* Create GROUP ACL */
|
||||
if (c->listen_acl_groups && *c->listen_acl_groups) {
|
||||
struct group *grp;
|
||||
|
||||
tmp = estrdup(c->listen_acl_groups);
|
||||
for (p=tmp ; p ; p=end) {
|
||||
if ((end = strchr(p, ','))) {
|
||||
*end++ = 0;
|
||||
}
|
||||
grp = getgrnam(p);
|
||||
if (grp) {
|
||||
zlog(ZLOG_DEBUG, "[pool %s] group '%s' have gid=%d", wp->config->name, p, grp->gr_gid);
|
||||
} else {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, p);
|
||||
acl_free(acl);
|
||||
efree(tmp);
|
||||
return -1;
|
||||
}
|
||||
if (0 > acl_create_entry(&acl, &entry) ||
|
||||
0 > acl_set_tag_type(entry, ACL_GROUP) ||
|
||||
0 > acl_set_qualifier(entry, &grp->gr_gid) ||
|
||||
0 > acl_get_permset(entry, &perm) ||
|
||||
0 > acl_clear_perms (perm) ||
|
||||
0 > acl_add_perm (perm, ACL_READ) ||
|
||||
0 > acl_add_perm (perm, ACL_WRITE)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] cannot create ACL for group '%s'", wp->config->name, p);
|
||||
acl_free(acl);
|
||||
efree(tmp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
efree(tmp);
|
||||
}
|
||||
if (c->listen_owner && *c->listen_owner) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] ACL set, listen.owner = '%s' is ignored", wp->config->name, c->listen_owner);
|
||||
}
|
||||
if (c->listen_group && *c->listen_group) {
|
||||
zlog(ZLOG_WARNING, "[pool %s] ACL set, listen.group = '%s' is ignored", wp->config->name, c->listen_group);
|
||||
}
|
||||
wp->socket_acl = acl;
|
||||
return 0;
|
||||
}
|
||||
/* When listen.users and listen.groups not configured, continue with standard right */
|
||||
#endif
|
||||
|
||||
if (c->listen_owner && *c->listen_owner) {
|
||||
struct passwd *pwd;
|
||||
|
||||
|
@ -69,18 +188,54 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
|
|||
wp->socket_gid = grp->gr_gid;
|
||||
}
|
||||
|
||||
if (c->listen_mode && *c->listen_mode) {
|
||||
wp->socket_mode = strtoul(c->listen_mode, 0, 8);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int fpm_unix_set_socket_premissions(struct fpm_worker_pool_s *wp, const char *path) /* {{{ */
|
||||
{
|
||||
#ifdef HAVE_FPM_ACL
|
||||
if (wp->socket_acl) {
|
||||
acl_t aclfile, aclconf;
|
||||
acl_entry_t entryfile, entryconf;
|
||||
int i;
|
||||
|
||||
/* Read the socket ACL */
|
||||
aclconf = wp->socket_acl;
|
||||
aclfile = acl_get_file (path, ACL_TYPE_ACCESS);
|
||||
if (!aclfile) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to read the ACL of the socket '%s'", wp->config->name, path);
|
||||
return -1;
|
||||
}
|
||||
/* Copy the new ACL entry from config */
|
||||
for (i=ACL_FIRST_ENTRY ; acl_get_entry(aclconf, i, &entryconf) ; i=ACL_NEXT_ENTRY) {
|
||||
if (0 > acl_create_entry (&aclfile, &entryfile) ||
|
||||
0 > acl_copy_entry(entryfile, entryconf)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to add entry to the ACL of the socket '%s'", wp->config->name, path);
|
||||
acl_free(aclfile);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Write the socket ACL */
|
||||
if (0 > acl_calc_mask (&aclfile) ||
|
||||
0 > acl_valid (aclfile) ||
|
||||
0 > acl_set_file (path, ACL_TYPE_ACCESS, aclfile)) {
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to write the ACL of the socket '%s'", wp->config->name, path);
|
||||
acl_free(aclfile);
|
||||
return -1;
|
||||
} else {
|
||||
zlog(ZLOG_DEBUG, "[pool %s] ACL of the socket '%s' is set", wp->config->name, path);
|
||||
}
|
||||
|
||||
acl_free(aclfile);
|
||||
return 0;
|
||||
}
|
||||
/* When listen.users and listen.groups not configured, continue with standard right */
|
||||
#endif
|
||||
|
||||
if (wp->socket_uid != -1 || wp->socket_gid != -1) {
|
||||
if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
|
||||
zlog(ZLOG_SYSERROR, "failed to chown() the socket '%s'", wp->config->listen_address);
|
||||
zlog(ZLOG_SYSERROR, "[pool %s] failed to chown() the socket '%s'", wp->config->name, wp->config->listen_address);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +243,17 @@ int fpm_unix_set_socket_premissions(struct fpm_worker_pool_s *wp, const char *pa
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
int fpm_unix_free_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
#ifdef HAVE_FPM_ACL
|
||||
if (wp->socket_acl) {
|
||||
return acl_free(wp->socket_acl);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
|
||||
{
|
||||
struct passwd *pwd;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp);
|
||||
int fpm_unix_set_socket_premissions(struct fpm_worker_pool_s *wp, const char *path);
|
||||
int fpm_unix_free_socket_premissions(struct fpm_worker_pool_s *wp);
|
||||
|
||||
int fpm_unix_init_child(struct fpm_worker_pool_s *wp);
|
||||
int fpm_unix_init_main();
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "fpm_shm.h"
|
||||
#include "fpm_scoreboard.h"
|
||||
#include "fpm_conf.h"
|
||||
#include "fpm_unix.h"
|
||||
|
||||
struct fpm_worker_pool_s *fpm_worker_all_pools;
|
||||
|
||||
|
@ -29,6 +30,7 @@ void fpm_worker_pool_free(struct fpm_worker_pool_s *wp) /* {{{ */
|
|||
if (wp->home) {
|
||||
free(wp->home);
|
||||
}
|
||||
fpm_unix_free_socket_premissions(wp);
|
||||
free(wp);
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -42,6 +42,10 @@ struct fpm_worker_pool_s {
|
|||
/* for ondemand PM */
|
||||
struct fpm_event_s *ondemand_event;
|
||||
int socket_event_set;
|
||||
|
||||
#ifdef HAVE_FPM_ACL
|
||||
void *socket_acl;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct fpm_worker_pool_s *fpm_worker_pool_alloc();
|
||||
|
|
|
@ -173,6 +173,11 @@ listen = 127.0.0.1:9000
|
|||
;listen.owner = @php_fpm_user@
|
||||
;listen.group = @php_fpm_group@
|
||||
;listen.mode = 0660
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a coma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
;listen.acl_users =
|
||||
;listen.acl_groups =
|
||||
|
||||
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
|
|
89
sapi/fpm/tests/021-uds-acl.phpt
Normal file
89
sapi/fpm/tests/021-uds-acl.phpt
Normal file
|
@ -0,0 +1,89 @@
|
|||
--TEST--
|
||||
FPM: Test Unix Domain Socket with Posix ACL
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "skipif.inc";
|
||||
if (!(file_exists('/usr/bin/getfacl') && file_exists('/etc/passwd') && file_exists('/etc/group'))) die ("skip missing getfacl command");
|
||||
?>
|
||||
--XFAIL--
|
||||
Mark as XFAIL because --with-fpm-acl is not enabled in default build
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "include.inc";
|
||||
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
$socket = dirname(__FILE__).'/php-fpm.sock';
|
||||
|
||||
// Select 3 users and 2 groups known by system (avoid root)
|
||||
$users = $groups = [];
|
||||
$tmp = file('/etc/passwd');
|
||||
for ($i=1 ; $i<=3 ; $i++) {
|
||||
$tab = explode(':', $tmp[$i]);
|
||||
$users[] = $tab[0];
|
||||
}
|
||||
$users = implode(',', $users);
|
||||
$tmp = file('/etc/group');
|
||||
for ($i=1 ; $i<=2 ; $i++) {
|
||||
$tab = explode(':', $tmp[$i]);
|
||||
$groups[] = $tab[0];
|
||||
}
|
||||
$groups = implode(',', $groups);
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = $logfile
|
||||
[unconfined]
|
||||
listen = $socket
|
||||
listen.acl_users = $users
|
||||
listen.acl_groups = $groups
|
||||
listen.mode = 0600
|
||||
ping.path = /ping
|
||||
ping.response = pong
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
EOT;
|
||||
|
||||
$fpm = run_fpm($cfg, $tail);
|
||||
if (is_resource($fpm)) {
|
||||
fpm_display_log($tail, 2);
|
||||
try {
|
||||
var_dump(strpos(run_request('unix://'.$socket, -1), 'pong'));
|
||||
echo "UDS ok\n";
|
||||
} catch (Exception $e) {
|
||||
echo "UDS error\n";
|
||||
}
|
||||
passthru("/usr/bin/getfacl -cp $socket");
|
||||
|
||||
proc_terminate($fpm);
|
||||
echo stream_get_contents($tail);
|
||||
fclose($tail);
|
||||
proc_close($fpm);
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
[%s] NOTICE: fpm is running, pid %d
|
||||
[%s] NOTICE: ready to handle connections
|
||||
int(%d)
|
||||
UDS ok
|
||||
user::rw-
|
||||
user:%s:rw-
|
||||
user:%s:rw-
|
||||
user:%s:rw-
|
||||
group::---
|
||||
group:%s:rw-
|
||||
group:%s:rw-
|
||||
mask::rw-
|
||||
other::---
|
||||
|
||||
[%s] NOTICE: Terminating ...
|
||||
[%s] NOTICE: exiting, bye-bye!
|
||||
--CLEAN--
|
||||
<?php
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
@unlink($logfile);
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue