Skip to content

Commit be7f405

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 55d34f7 + 4a9f78f commit be7f405

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

ext/curl/interface.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ static ZEND_ATTRIBUTE_UNUSED unsigned long php_curl_ssl_id(void)
9797
static void _php_curl_close_ex(php_curl *ch);
9898
static void _php_curl_close(zend_resource *rsrc);
9999

100-
#define SAVE_CURL_ERROR(__handle, __err) \
101-
do { (__handle)->err.no = (int) __err; } while (0)
102-
103100
#define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s) - 1, (zend_long) v);
104101
#define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s) - 1, (double) v);
105102
#define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s) - 1, (char *) (v ? v : ""));

ext/curl/multi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ PHP_FUNCTION(curl_multi_info_read)
333333
CURLMsg *tmp_msg;
334334
int queued_msgs;
335335
zval *zmsgs_in_queue = NULL;
336+
php_curl *ch;
336337

337338
ZEND_PARSE_PARAMETERS_START(1, 2)
338339
Z_PARAM_RESOURCE(z_mh)
@@ -370,6 +371,10 @@ PHP_FUNCTION(curl_multi_info_read)
370371
being done in add_assoc_resource */
371372
Z_ADDREF_P(pz_ch);
372373

374+
/* we must save result to be able to read error message */
375+
ch = (php_curl*)zend_fetch_resource(Z_RES_P(pz_ch), le_curl_name, le_curl);
376+
SAVE_CURL_ERROR(ch, tmp_msg->data.result);
377+
373378
/* add_assoc_resource automatically creates a new zval to
374379
wrap the "resource" represented by the current pz_ch */
375380

ext/curl/php_curl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ extern zend_module_entry curl_module_entry;
5858
#define PHP_CURL_RETURN 4
5959
#define PHP_CURL_IGNORE 7
6060

61+
#define SAVE_CURL_ERROR(__handle, __err) \
62+
do { (__handle)->err.no = (int) __err; } while (0)
63+
6164
extern int le_curl;
6265
#define le_curl_name "cURL handle"
6366
extern int le_curl_multi_handle;

ext/curl/tests/bug77946.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Bug #77946 (Errored cURL resources returned by curl_multi_info_read() must be compatible with curl_errno() and curl_error())
3+
--SKIPIF--
4+
<?php
5+
6+
if (!extension_loaded('curl')) {
7+
exit('skip curl extension not loaded');
8+
}
9+
10+
?>
11+
--FILE--
12+
<?php
13+
$urls = array(
14+
'unknown://scheme.tld',
15+
);
16+
17+
$mh = curl_multi_init();
18+
19+
foreach ($urls as $i => $url) {
20+
$conn[$i] = curl_init($url);
21+
curl_multi_add_handle($mh, $conn[$i]);
22+
}
23+
24+
do {
25+
$status = curl_multi_exec($mh, $active);
26+
$info = curl_multi_info_read($mh);
27+
if (false !== $info) {
28+
var_dump($info['result']);
29+
var_dump(curl_errno($info['handle']));
30+
var_dump(curl_error($info['handle']));
31+
}
32+
} while ($status === CURLM_CALL_MULTI_PERFORM || $active);
33+
34+
foreach ($urls as $i => $url) {
35+
curl_close($conn[$i]);
36+
}
37+
38+
curl_multi_close($mh);
39+
?>
40+
--EXPECTF--
41+
int(1)
42+
int(1)
43+
string(%d) "Protocol %Sunknown%S not supported or disabled in libcurl"

0 commit comments

Comments
 (0)