summaryrefslogtreecommitdiff
path: root/ext/curl
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2019-03-01 01:37:00 -0500
committerNikita Popov <nikita.ppv@gmail.com>2019-03-01 14:54:37 +0100
commit5025eb05bde83a0a51eb0668c45c240b366545bf (patch)
treeeecd6c6f6c9cf5b8656bbb39e97342f7c0b6a522 /ext/curl
parent006355c9fa0d1cd8aef86a97c162053e7d2d896e (diff)
downloadphp-git-5025eb05bde83a0a51eb0668c45c240b366545bf.tar.gz
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
Diffstat (limited to 'ext/curl')
-rw-r--r--ext/curl/interface.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 3af7ec12e2..a252bb3a21 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();
+ }
}
/* }}} */