blob: b95677c12ecaec6b8843d7e9234ae0034f719c85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
From 5025eb05bde83a0a51eb0668c45c240b366545bf Mon Sep 17 00:00:00 2001
From: Jay Satiro <raysatiro@yahoo.com>
Date: Fri, 1 Mar 2019 01:37:00 -0500
Subject: [PATCH] curl_error: return an empty string if no error occurred
CURLOPT_ERRORBUFFER doc says "Do not rely on the contents of the
buffer unless an error code was returned." [1]
Prior to this change the error buffer was returned even if no error had
occurred, and that buffer may contain incorrect information in such a
case. [2]
[1]: https://curl.haxx.se/libcurl/c/CURLOPT_ERRORBUFFER.html
[2]: https://github.com/curl/curl/issues/3629
---
ext/curl/interface.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 3af7ec12e23c..a252bb3a219d 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -3310,8 +3310,12 @@ PHP_FUNCTION(curl_error)
RETURN_FALSE;
}
- ch->err.str[CURL_ERROR_SIZE] = 0;
- RETURN_STRING(ch->err.str);
+ if (ch->err.no) {
+ ch->err.str[CURL_ERROR_SIZE] = 0;
+ RETURN_STRING(ch->err.str);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
|