com php-src: curl_error: return an empty string i f no error occurred: ext/curl/interface.c

From: Date: Fri, 01 Mar 2019 13:54:37 +0000
Subject: com php-src: curl_error: return an empty string i f no error occurred: ext/curl/interface.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104929@lists.php.net to get a copy of this message
Commit: 5025eb05bde83a0a51eb0668c45c240b366545bf Author: Jay Satiro <raysatiro@yahoo.com> Fri, 1 Mar 2019 01:37:00 -0500 Committer: Nikita Popov <nikita.ppv@gmail.com> Fri, 1 Mar 2019 14:54:37 +0100 Parents: 006355c9fa0d1cd8aef86a97c162053e7d2d896e Branches: PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5025eb05bde83a0a51eb0668c45c240b366545bf Log: 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 Changed paths: M ext/curl/interface.c Diff: diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 3af7ec1..a252bb3 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(); + } } /* }}} */

« previous php.cvs (#104929) next »