I extended a patch from David Shaw to make libcurl _always_ provide an error

string in the given error buffer to address the flaw mention on 21 sep 2005.
This commit is contained in:
Daniel Stenberg
2005-11-17 14:29:54 +00:00
parent 39e366fc11
commit 4022a60ea7
4 changed files with 19 additions and 7 deletions

View File

@@ -2217,6 +2217,19 @@ CURLcode Curl_perform(struct SessionHandle *data)
if(newurl)
free(newurl);
if(res && !data->state.errorbuf) {
/*
* As an extra precaution: if no error string has been set and there was
* an error, use the strerror() string or if things are so bad that not
* even that is good, set a bad string that mentions the error code.
*/
char *str = curl_easy_strerror(res);
if(!str)
failf(data, "unspecified error %d", (int)res);
else
failf(data, "%s", str);
}
/* run post-transfer uncondionally, but don't clobber the return code if
we already have an error code recorder */
res2 = Curl_posttransfer(data);