From 4022a60ea7f88650f1b4abfe1e41c973cca7861d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 17 Nov 2005 14:29:54 +0000 Subject: 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. --- lib/transfer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/transfer.c b/lib/transfer.c index 1706ccb6f..664a412bd 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -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); -- cgit v1.2.3