Skip to content

Commit 2b89919

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix GH-21023: CURLOPT_XFERINFOFUNCTION with invalid callback crash.
2 parents e9ae040 + b156471 commit 2b89919

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

ext/curl/interface.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
578578
zval argv[3];
579579
zval retval;
580580

581+
if (!ZEND_FCC_INITIALIZED(ch->handlers.fnmatch)) {
582+
return rval;
583+
}
584+
581585
GC_ADDREF(&ch->std);
582586
ZVAL_OBJ(&argv[0], &ch->std);
583587
ZVAL_STRING(&argv[1], pattern);
@@ -609,6 +613,9 @@ static int curl_progress(void *clientp, double dltotal, double dlnow, double ult
609613
fprintf(stderr, "curl_progress() called\n");
610614
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
611615
#endif
616+
if (!ZEND_FCC_INITIALIZED(ch->handlers.progress)) {
617+
return rval;
618+
}
612619

613620
zval args[5];
614621
zval retval;
@@ -647,6 +654,9 @@ static int curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, cu
647654
fprintf(stderr, "curl_xferinfo() called\n");
648655
fprintf(stderr, "clientp = %x, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow);
649656
#endif
657+
if (!ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) {
658+
return rval;
659+
}
650660

651661
zval argv[5];
652662
zval retval;

ext/curl/tests/gh21023.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
GH-21023 (crash with CURLOPT_XFERINFOFUNCTION set with an invalid callback)
3+
--EXTENSIONS--
4+
curl
5+
--FILE--
6+
<?php
7+
include 'server.inc';
8+
$host = curl_cli_server_start();
9+
$url = "{$host}/get.inc";
10+
$ch = curl_init($url);
11+
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
12+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
13+
curl_setopt($ch, CURLOPT_XFERINFOFUNCTION, null);
14+
curl_exec($ch);
15+
$ch = curl_init($url);
16+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
17+
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, null);
18+
curl_exec($ch);
19+
$ch = curl_init($url);
20+
curl_setopt($ch, CURLOPT_WILDCARDMATCH, 1);
21+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
22+
curl_setopt($ch, CURLOPT_FNMATCH_FUNCTION, null);
23+
curl_exec($ch);
24+
echo "OK", PHP_EOL;
25+
?>
26+
--EXPECT--
27+
OK

0 commit comments

Comments
 (0)