[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 15/178: add_handle/easy_perform: clear errorbuffer
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 15/178: add_handle/easy_perform: clear errorbuffer on start if set |
Date: |
Wed, 23 May 2018 12:24:10 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit fb4f568b1e090c884eb63c3419322b558a38138e
Author: Daniel Stenberg <address@hidden>
AuthorDate: Tue Mar 13 00:51:39 2018 +0100
add_handle/easy_perform: clear errorbuffer on start if set
To offer applications a more defined behavior, we clear the buffer as
early as possible.
Assisted-by: Jay Satiro
Fixes #2190
Closes #2377
---
docs/libcurl/opts/CURLOPT_ERRORBUFFER.3 | 12 +++++++-----
lib/easy.c | 4 ++++
lib/multi.c | 2 ++
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3
b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3
index b64a2a394..71cce945b 100644
--- a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3
+++ b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.3
@@ -28,8 +28,8 @@ CURLOPT_ERRORBUFFER \- set error buffer for error messages
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ERRORBUFFER, char *buf);
.SH DESCRIPTION
-Pass a char * to a buffer that the libcurl may store human readable error
-messages in on failures or problems. This may be more helpful than just the
+Pass a char * to a buffer that libcurl \fBmay\fP store human readable error
+messages on failures or problems. This may be more helpful than just the
return code from \fIcurl_easy_perform(3)\fP and related functions. The buffer
\fBmust be at least CURL_ERROR_SIZE bytes big\fP.
@@ -38,11 +38,13 @@ it. Failing to do so will cause very odd behavior or even
crashes. libcurl
will need it until you call \fIcurl_easy_cleanup(3)\fP or you set the same
option again to use a different pointer.
+Do not rely on the contents of the buffer unless an error code was returned.
+Since 7.60.0 libcurl will initialize the contents of the error buffer to an
+empty string before performing the transfer. For earlier versions if an error
+code was returned but there was no error detail then the buffer is untouched.
+
Consider \fICURLOPT_VERBOSE(3)\fP and \fICURLOPT_DEBUGFUNCTION(3)\fP to better
debug and trace why errors happen.
-
-If the library does not return an error, the buffer may not have been
-touched. Do not rely on the contents in those cases.
.SH DEFAULT
NULL
.SH PROTOCOLS
diff --git a/lib/easy.c b/lib/easy.c
index fa34c3827..c99758617 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -746,6 +746,10 @@ static CURLcode easy_perform(struct Curl_easy *data, bool
events)
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(data->set.errorbuffer)
+ /* clear this as early as possible */
+ data->set.errorbuffer[0] = 0;
+
if(data->multi) {
failf(data, "easy handle already used in multi handle");
return CURLE_FAILED_INIT;
diff --git a/lib/multi.c b/lib/multi.c
index 0a1dba391..822ac3b1e 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -379,6 +379,8 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
* potential multi's connection cache growing which won't be undone in this
* function no matter what.
*/
+ if(data->set.errorbuffer)
+ data->set.errorbuffer[0] = 0;
/* set the easy handle */
multistate(data, CURLM_STATE_INIT);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 03/178: test1208: marked flaky, (continued)
- [GNUnet-SVN] [gnurl] 03/178: test1208: marked flaky, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 19/178: cmake: add support for brotli, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 16/178: resolve: add CURLOPT_DNS_SHUFFLE_ADDRESSES, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 09/178: rate-limit: use three second window to better handle high speeds, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 27/178: cookie.d: mention that "-" as filename means stdin, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 18/178: darwinssl: fix iOS build, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 21/178: parsedate: support UT timezone, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 11/178: pause: when changing pause state, update socket state, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 13/178: curl_version_info.3: fix ssl_version description, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 31/178: http2: read pending frames (including GOAWAY) in connection-check, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 15/178: add_handle/easy_perform: clear errorbuffer on start if set,
gnunet <=
- [GNUnet-SVN] [gnurl] 28/178: TODO: expand ~/ in config files, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 32/178: timeval: remove compilation warning by casting (#2417), gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 23/178: vauth/ntlm.h: fix the #ifdef header guard, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 08/178: cleanup: misc typos in strings and comments, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 29/178: CURLINFO_SSL_VERIFYRESULT.3: fix the example, add some text, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 38/178: runtests.pl: fix warning 'use of uninitialized value', gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 24/178: lib/curl_path.h: add #ifdef header guard, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 33/178: cmake: avoid warn-as-error during config checks (#2411), gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 25/178: vauth/cleartext: fix integer overflow check, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 26/178: CURLINFO_COOKIELIST.3: made the example not leak memory, gnunet, 2018/05/23