Skip to content

Commit 09e6031

Browse files
authored
Merge branch 'php:master' into true-async-api
2 parents 085e265 + 89934b4 commit 09e6031

File tree

156 files changed

+751
-1155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+751
-1155
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ PHP NEWS
202202
. Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos)
203203
. Implement request #55503 (Extend __getTypes to support enumerations).
204204
(nielsdos, datibbaw)
205+
. Implement request #61105 (Support Soap 1.2 SoapFault Reason Text lang
206+
attribute). (nielsdos)
205207

206208
- Sockets:
207209
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ PHP 8.5 UPGRADE NOTES
204204

205205
- SOAP:
206206
. Enumeration cases are now dumped in __getTypes().
207+
. Implemented request #61105:
208+
support for Soap 1.2 Reason Text xml:lang attribute.
209+
The signature of SoapFault::__construct() and SoapServer::fault() therefore
210+
now have an optional $lang parameter.
211+
This support solves compatibility with .NET SOAP clients.
207212

208213
- XSL:
209214
. The $namespace argument of XSLTProcessor::getParameter(),

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ PHP 8.5 INTERNALS UPGRADE NOTES
5252
- Linux build system changes
5353
. libdir is properly set when --libdir (ex: /usr/lib64) and --with-libdir (ex lib64)
5454
configure options are used to ${libdir}/php (ex: /usr/lib64/php)
55+
. PHP_ODBC_CFLAGS, PHP_ODBC_LFLAGS, PHP_ODBC_LIBS, PHP_ODBC_TYPE preprocessor
56+
macros defined by ext/odbc are now defined in php_config.h instead of the
57+
build-defs.h header.
5558

5659
========================
5760
3. Module changes

Zend/tests/gh18833.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-18833 (Use after free with weakmaps dependent on destruction order)
3+
--FILE--
4+
<?php
5+
6+
class a {
7+
public static WeakMap $map;
8+
public static Generator $storage;
9+
}
10+
11+
a::$map = new WeakMap;
12+
13+
$closure = function () {
14+
$obj = new a;
15+
a::$map[$obj] = true;
16+
yield $obj;
17+
};
18+
a::$storage = $closure();
19+
a::$storage->current();
20+
21+
echo "ok\n";
22+
?>
23+
--EXPECT--
24+
ok

Zend/zend_alloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,7 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
24322432
}
24332433
#if ZEND_MM_STAT
24342434
heap->size = 0;
2435+
heap->real_size = 0;
24352436
#endif
24362437
}
24372438

@@ -2999,6 +3000,7 @@ static void *tracked_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
29993000
tracked_add(heap, ptr, size);
30003001
#if ZEND_MM_STAT
30013002
heap->size += size;
3003+
heap->real_size = heap->size;
30023004
#endif
30033005
return ptr;
30043006
}
@@ -3012,6 +3014,7 @@ static void tracked_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
30123014
zval *size_zv = tracked_get_size_zv(heap, ptr);
30133015
#if ZEND_MM_STAT
30143016
heap->size -= Z_LVAL_P(size_zv);
3017+
heap->real_size = heap->size;
30153018
#endif
30163019
zend_hash_del_bucket(heap->tracked_allocs, (Bucket *) size_zv);
30173020
free(ptr);
@@ -3039,6 +3042,7 @@ static void *tracked_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_F
30393042
tracked_add(heap, ptr, new_size);
30403043
#if ZEND_MM_STAT
30413044
heap->size += new_size - old_size;
3045+
heap->real_size = heap->size;
30423046
#endif
30433047
return ptr;
30443048
}

Zend/zend_objects_API.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
100100
if (IS_OBJ_VALID(obj)) {
101101
if (!(OBJ_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
102102
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
103-
if (obj->handlers->free_obj != zend_object_std_dtor) {
103+
if (obj->handlers->free_obj != zend_object_std_dtor
104+
|| (OBJ_FLAGS(obj) & IS_OBJ_WEAKLY_REFERENCED)
105+
) {
104106
GC_ADDREF(obj);
105107
obj->handlers->free_obj(obj);
106108
}

ext/bcmath/libbcmath/src/compare.c

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@
3939
than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just
4040
compare the magnitudes. */
4141

42+
static inline bcmath_compare_result bc_compare_get_result_val(bool left_abs_greater, bool use_sign, sign left_sign)
43+
{
44+
if (left_abs_greater) {
45+
/* Magnitude of left > right. */
46+
if (!use_sign || left_sign == PLUS) {
47+
return BCMATH_LEFT_GREATER;
48+
} else {
49+
return BCMATH_RIGHT_GREATER;
50+
}
51+
} else {
52+
/* Magnitude of left < right. */
53+
if (!use_sign || left_sign == PLUS) {
54+
return BCMATH_RIGHT_GREATER;
55+
} else {
56+
return BCMATH_LEFT_GREATER;
57+
}
58+
}
59+
}
60+
4261
bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool use_sign)
4362
{
4463
/* First, compare signs. */
@@ -66,21 +85,7 @@ bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool us
6685

6786
/* Now compare the magnitude. */
6887
if (n1->n_len != n2->n_len) {
69-
if (n1->n_len > n2->n_len) {
70-
/* Magnitude of n1 > n2. */
71-
if (!use_sign || n1->n_sign == PLUS) {
72-
return BCMATH_LEFT_GREATER;
73-
} else {
74-
return BCMATH_RIGHT_GREATER;
75-
}
76-
} else {
77-
/* Magnitude of n1 < n2. */
78-
if (!use_sign || n1->n_sign == PLUS) {
79-
return BCMATH_RIGHT_GREATER;
80-
} else {
81-
return BCMATH_LEFT_GREATER;
82-
}
83-
}
88+
return bc_compare_get_result_val(n1->n_len > n2->n_len, use_sign, n1->n_sign);
8489
}
8590

8691
size_t n1_scale = MIN(n1->n_scale, scale);
@@ -92,28 +97,32 @@ bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool us
9297
const char *n1ptr = n1->n_value;
9398
const char *n2ptr = n2->n_value;
9499

100+
while (count >= sizeof(BC_VECTOR)) {
101+
BC_VECTOR n1bytes;
102+
BC_VECTOR n2bytes;
103+
memcpy(&n1bytes, n1ptr, sizeof(BC_VECTOR));
104+
memcpy(&n2bytes, n2ptr, sizeof(BC_VECTOR));
105+
106+
if (n1bytes != n2bytes) {
107+
#if BC_LITTLE_ENDIAN
108+
n1bytes = BC_BSWAP(n1bytes);
109+
n2bytes = BC_BSWAP(n2bytes);
110+
#endif
111+
return bc_compare_get_result_val(n1bytes > n2bytes, use_sign, n1->n_sign);
112+
}
113+
count -= sizeof(BC_VECTOR);
114+
n1ptr += sizeof(BC_VECTOR);
115+
n2ptr += sizeof(BC_VECTOR);
116+
}
117+
95118
while ((count > 0) && (*n1ptr == *n2ptr)) {
96119
n1ptr++;
97120
n2ptr++;
98121
count--;
99122
}
100123

101124
if (count != 0) {
102-
if (*n1ptr > *n2ptr) {
103-
/* Magnitude of n1 > n2. */
104-
if (!use_sign || n1->n_sign == PLUS) {
105-
return BCMATH_LEFT_GREATER;
106-
} else {
107-
return BCMATH_RIGHT_GREATER;
108-
}
109-
} else {
110-
/* Magnitude of n1 < n2. */
111-
if (!use_sign || n1->n_sign == PLUS) {
112-
return BCMATH_RIGHT_GREATER;
113-
} else {
114-
return BCMATH_LEFT_GREATER;
115-
}
116-
}
125+
return bc_compare_get_result_val(*n1ptr > *n2ptr, use_sign, n1->n_sign);
117126
}
118127

119128
/* They are equal up to the last part of the equal part of the fraction. */

ext/curl/curl_private.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ void _php_curl_multi_cleanup_list(void *data);
150150
void _php_curl_verify_handlers(php_curl *ch, bool reporterror);
151151
void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source);
152152

153+
/* Consumes `zv` */
154+
zend_long php_curl_get_long(zval *zv);
155+
153156
static inline php_curl *curl_from_obj(zend_object *obj) {
154157
return (php_curl *)((char *)(obj) - XtOffsetOf(php_curl, std));
155158
}

ext/curl/interface.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
624624
if (!Z_ISUNDEF(retval)) {
625625
_php_curl_verify_handlers(ch, /* reporterror */ true);
626626
/* TODO Check callback returns an int or something castable to int */
627-
length = zval_get_long(&retval);
627+
length = php_curl_get_long(&retval);
628628
}
629629

630630
zval_ptr_dtor(&argv[0]);
@@ -657,7 +657,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
657657
if (!Z_ISUNDEF(retval)) {
658658
_php_curl_verify_handlers(ch, /* reporterror */ true);
659659
/* TODO Check callback returns an int or something castable to int */
660-
rval = zval_get_long(&retval);
660+
rval = php_curl_get_long(&retval);
661661
}
662662
zval_ptr_dtor(&argv[0]);
663663
zval_ptr_dtor(&argv[1]);
@@ -694,7 +694,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
694694
if (!Z_ISUNDEF(retval)) {
695695
_php_curl_verify_handlers(ch, /* reporterror */ true);
696696
/* TODO Check callback returns an int or something castable to int */
697-
if (0 != zval_get_long(&retval)) {
697+
if (0 != php_curl_get_long(&retval)) {
698698
rval = 1;
699699
}
700700
}
@@ -732,7 +732,7 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
732732
if (!Z_ISUNDEF(retval)) {
733733
_php_curl_verify_handlers(ch, /* reporterror */ true);
734734
/* TODO Check callback returns an int or something castable to int */
735-
if (0 != zval_get_long(&retval)) {
735+
if (0 != php_curl_get_long(&retval)) {
736736
rval = 1;
737737
}
738738
}
@@ -831,6 +831,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
831831
}
832832
} else {
833833
zend_throw_error(NULL, "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH");
834+
zval_ptr_dtor(&retval);
834835
}
835836
}
836837

@@ -925,7 +926,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
925926
if (!Z_ISUNDEF(retval)) {
926927
// TODO: Check for valid int type for return value
927928
_php_curl_verify_handlers(ch, /* reporterror */ true);
928-
length = zval_get_long(&retval);
929+
length = php_curl_get_long(&retval);
929930
}
930931
zval_ptr_dtor(&argv[0]);
931932
zval_ptr_dtor(&argv[1]);
@@ -1343,6 +1344,17 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
13431344
(*source->clone)++;
13441345
}
13451346

1347+
zend_long php_curl_get_long(zval *zv)
1348+
{
1349+
if (EXPECTED(Z_TYPE_P(zv) == IS_LONG)) {
1350+
return Z_LVAL_P(zv);
1351+
} else {
1352+
zend_long ret = zval_get_long(zv);
1353+
zval_ptr_dtor(zv);
1354+
return ret;
1355+
}
1356+
}
1357+
13461358
static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
13471359
{
13481360
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;

ext/curl/multi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
435435
zval_ptr_dtor_nogc(&headers);
436436

437437
if (!Z_ISUNDEF(retval)) {
438-
if (CURL_PUSH_DENY != zval_get_long(&retval)) {
438+
if (CURL_PUSH_DENY != php_curl_get_long(&retval)) {
439439
rval = CURL_PUSH_OK;
440440
zend_llist_add_element(&mh->easyh, &pz_ch);
441441
} else {

0 commit comments

Comments
 (0)