Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ PHP NEWS
. Fixed bug GH-20370 (User stream filters could violate typed property
constraints). (alexandre-daubois)
. Allowed filtered streams to be casted as fd for select. (Jakub Zelenka)
. Fixed bug GH-21221 (Prevent closing of innerstream of php://temp stream).
(ilutov)

- Zip:
. Fixed ZipArchive callback being called after executor has shut down.
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
internal_function->prop_info = NULL;
internal_function->attributes = NULL;
internal_function->frameless_function_infos = ptr->frameless_function_infos;
internal_function->fn_flags2 = 0;
if (EG(active)) { // at run-time: this ought to only happen if registered with dl() or somehow temporarily at runtime
ZEND_MAP_PTR_INIT(internal_function->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
} else {
Expand Down
32 changes: 16 additions & 16 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4344,7 +4344,7 @@ static void function_to_string(sdlFunctionPtr function, smart_str *buf) /* {{{ *
zend_hash_internal_pointer_reset(function->responseParameters);
param = zend_hash_get_current_data_ptr(function->responseParameters);
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
smart_str_appends(buf, param->encode->details.type_str);
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "UNKNOWN ", 8);
Expand All @@ -4357,12 +4357,12 @@ static void function_to_string(sdlFunctionPtr function, smart_str *buf) /* {{{ *
smart_str_appendl(buf, ", ", 2);
}
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
smart_str_appends(buf, param->encode->details.type_str);
} else {
smart_str_appendl(buf, "UNKNOWN", 7);
}
smart_str_appendl(buf, " $", 2);
smart_str_appendl(buf, param->paramName, strlen(param->paramName));
smart_str_appends(buf, param->paramName);
i++;
} ZEND_HASH_FOREACH_END();
smart_str_appendl(buf, ") ", 2);
Expand All @@ -4371,7 +4371,7 @@ static void function_to_string(sdlFunctionPtr function, smart_str *buf) /* {{{ *
smart_str_appendl(buf, "void ", 5);
}

smart_str_appendl(buf, function->functionName, strlen(function->functionName));
smart_str_appends(buf, function->functionName);

smart_str_appendc(buf, '(');
if (function->requestParameters) {
Expand All @@ -4381,12 +4381,12 @@ static void function_to_string(sdlFunctionPtr function, smart_str *buf) /* {{{ *
smart_str_appendl(buf, ", ", 2);
}
if (param->encode && param->encode->details.type_str) {
smart_str_appendl(buf, param->encode->details.type_str, strlen(param->encode->details.type_str));
smart_str_appends(buf, param->encode->details.type_str);
} else {
smart_str_appendl(buf, "UNKNOWN", 7);
}
smart_str_appendl(buf, " $", 2);
smart_str_appendl(buf, param->paramName, strlen(param->paramName));
smart_str_appends(buf, param->paramName);
i++;
} ZEND_HASH_FOREACH_END();
}
Expand Down Expand Up @@ -4442,12 +4442,12 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
switch (type->kind) {
case XSD_TYPEKIND_SIMPLE:
if (type->encode) {
smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
smart_str_appends(buf, type->encode->details.type_str);
smart_str_appendc(buf, ' ');
} else {
smart_str_appendl(buf, "anyType ", sizeof("anyType ")-1);
}
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);

if (type->restrictions && type->restrictions->enumeration) {
zend_string *key;
Expand All @@ -4467,20 +4467,20 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
break;
case XSD_TYPEKIND_LIST:
smart_str_appendl(buf, "list ", 5);
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);
if (type->elements) {
sdlTypePtr item_type;

smart_str_appendl(buf, " {", 2);
ZEND_HASH_FOREACH_PTR(type->elements, item_type) {
smart_str_appendl(buf, item_type->name, strlen(item_type->name));
smart_str_appends(buf, item_type->name);
} ZEND_HASH_FOREACH_END();
smart_str_appendc(buf, '}');
}
break;
case XSD_TYPEKIND_UNION:
smart_str_appendl(buf, "union ", 6);
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);
if (type->elements) {
sdlTypePtr item_type;
int first = 0;
Expand All @@ -4491,7 +4491,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
smart_str_appendc(buf, ',');
first = 0;
}
smart_str_appendl(buf, item_type->name, strlen(item_type->name));
smart_str_appends(buf, item_type->name);
} ZEND_HASH_FOREACH_END();
smart_str_appendc(buf, '}');
}
Expand Down Expand Up @@ -4523,7 +4523,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
smart_str_appendl(buf, ext->val, len);
}
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);
if (end != NULL) {
smart_str_appends(buf, end);
}
Expand All @@ -4546,7 +4546,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
} else {
smart_str_appendl(buf, "anyType ", 8);
}
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);
if (type->attributes &&
(attr = zend_hash_str_find_ptr(type->attributes, SOAP_1_2_ENC_NAMESPACE":arraySize",
sizeof(SOAP_1_2_ENC_NAMESPACE":arraySize")-1)) != NULL &&
Expand All @@ -4561,7 +4561,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
}
} else {
smart_str_appendl(buf, "struct ", 7);
smart_str_appendl(buf, type->name, strlen(type->name));
smart_str_appends(buf, type->name);
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, "{\n", 2);
if ((type->kind == XSD_TYPEKIND_RESTRICTION ||
Expand All @@ -4579,7 +4579,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s));
}
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
smart_str_appends(buf, type->encode->details.type_str);
smart_str_appendl(buf, " _;\n", 4);
}
}
Expand Down
14 changes: 14 additions & 0 deletions ext/standard/tests/gh21221.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-21221: Prevent closing of innerstream of php://temp stream
--CREDITS--
chongwick
--FILE--
<?php

$f = fopen('php://temp', 'r+b');
$resources = get_resources();
fclose(end($resources));

?>
--EXPECTF--
Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d
1 change: 1 addition & 0 deletions main/streams/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ PHPAPI php_stream *php_stream_encloses(php_stream *enclosing, php_stream *enclos
php_stream *orig = enclosed->enclosing_stream;

php_stream_auto_cleanup(enclosed);
enclosed->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
enclosed->enclosing_stream = enclosing;
return orig;
}
Expand Down