summaryrefslogtreecommitdiff
path: root/lib/strerror.c
Commit message (Collapse)AuthorAgeFilesLines
* urlapi: add curl_url_strerror()i-ky2021-09-271-0/+72
| | | | | | | | | | Add curl_url_strerror() to convert CURLUcode into readable string and facilitate easier troubleshooting in programs using URL API. Extend CURLUcode with CURLU_LAST for iteration in unit tests. Update man pages with a mention of new function. Update example code and tests with new functionality where it fits. Closes #7605
* strerror: use sys_errlist instead of strerror on WindowsJay Satiro2021-09-171-2/+2
| | | | | | | | | | | | | | | - Change Curl_strerror to use sys_errlist[errnum] instead of strerror to retrieve the error message on Windows. Windows' strerror writes to a static buffer and is not thread-safe. Follow-up to 2f0bb86 which removed most instances of strerror in favor of calling Curl_strerror (which calls strerror_r for other platforms). Ref: https://github.com/curl/curl/pull/7685 Ref: https://github.com/curl/curl/commit/2f0bb86 Closes https://github.com/curl/curl/pull/7735
* lib: don't use strerror()Daniel Stenberg2021-09-091-0/+1
| | | | | | | | | | We have and provide Curl_strerror() internally for a reason: strerror() is not necessarily thread-safe so we should always try to avoid it. Extended checksrc to warn for this, but feature the check disabled by default and only enable it in lib/ Closes #7685
* CURLE_SETOPT_OPTION_SYNTAX: new error name for wrong setopt syntaxDaniel Stenberg2021-06-021-2/+2
| | | | | | | | | For options that pass in lists or strings that are subsequently parsed and must be correct. This broadens the scope for the option previously known as CURLE_TELNET_OPTION_SYNTAX but the old name is of course still provided as a #define for existing applications. Closes #7175
* CURLcode: add CURLE_SSL_CLIENTCERTejanchivdorj2021-05-031-1/+4
| | | | | | | | | | When a TLS server requests a client certificate during handshake and none can be provided, libcurl now returns this new error code CURLE_SSL_CLIENTCERT Only supported by Secure Transport and OpenSSL for TLS 1.3 so far. Closes #6721
* copyright: fix missing year (range) updatesDaniel Stenberg2021-01-291-1/+1
|
* strerror: skip errnum >= 0 assertion on windowsJay Satiro2021-01-221-0/+2
| | | | | | | | | On Windows an error number may be greater than INT_MAX and negative once cast to int. The assertion is checked only in debug builds. Closes https://github.com/curl/curl/pull/6504
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* strerror: use 'const' as the string should never be modifiedPhilipp Klaus Krause2020-10-151-1/+1
| | | | Closes #6068
* strerror: Revert to local codepage for Windows error stringJay Satiro2020-10-131-16/+15
| | | | | | | | | | | | | | | | | | | | - Change get_winapi_error() to return the error string in the local codepage instead of UTF-8 encoding. Two weeks ago bed5f84 fixed get_winapi_error() to work on xbox, but it also changed the error string's encoding from local codepage to UTF-8. We return the local codepage version of the error string because if it is output to the user's terminal it will likely be with functions which expect the local codepage (eg fprintf, failf, infof). This is essentially a partial revert of bed5f84. The support for xbox remains but the error string is reverted back to local codepage. Ref: https://github.com/curl/curl/pull/6005 Reviewed-by: Marcel Raad Closes #6065
* strerror: fix null deref on winapi out-of-memoryJay Satiro2020-10-011-3/+5
| | | | | | Follow-up to bed5f84 from several days ago. Ref: https://github.com/curl/curl/pull/6005
* strerror: honor Unicode API choice on WindowsJavier Blazquez2020-09-251-15/+7
| | | | Closes #6005
* CURLE_PROXY: new error codeDaniel Stenberg2020-08-241-0/+3
| | | | | | | | | | | | Failures clearly returned from a (SOCKS) proxy now causes this return code. Previously the situation was not very clear as what would be returned and when. In addition: when this error code is returned, an application can use CURLINFO_PROXY_ERROR to query libcurl for the detailed error, which then returns a value from the new 'CURLproxycode' enum. Closes #5770
* terminology: call them null-terminated stringsDaniel Stenberg2020-06-281-1/+1
| | | | | | | | | | | Updated terminology in docs, comments and phrases to refer to C strings as "null-terminated". Done to unify with how most other C oriented docs refer of them and what users in general seem to prefer (based on a single highly unscientific poll on twitter). Reported-by: coinhubs on github Fixes #5598 Closes #5608
* ngtcp2: Add an error code for QUIC connection errorsEmil Engler2020-01-111-0/+3
| | | | | | | | | | - Add new error code CURLE_QUIC_CONNECT_ERROR for QUIC connection errors. Prior to this change CURLE_FAILED_INIT was used, but that was not correct. Closes https://github.com/curl/curl/pull/4754
* multi: Change curl_multi_wait/poll to error on negative timeoutJay Satiro2020-01-111-0/+3
| | | | | | | | | | | | | | - Add new error CURLM_BAD_FUNCTION_ARGUMENT and return that error when curl_multi_wait/poll is passed timeout param < 0. Prior to this change passing a negative value to curl_multi_wait/poll such as -1 could cause the function to wait forever. Reported-by: hamstergene@users.noreply.github.com Fixes https://github.com/curl/curl/issues/4763 Closes https://github.com/curl/curl/pull/4765
* lib: fix compiler warnings with `CURL_DISABLE_VERBOSE_STRINGS`Marcel Raad2020-01-031-1/+4
| | | | Closes https://github.com/curl/curl/pull/4775
* strerror: Fix compiler warning "empty expression"Gisle Vanem2019-12-181-1/+1
| | | | | | | | | | | | | - Remove the final semi-colon in the SEC2TXT() macro definition. Before: #define SEC2TXT(sec) case sec: txt = #sec; break; After: #define SEC2TXT(sec) case sec: txt = #sec; break Prior to this change SEC2TXT(foo); would generate break;; which caused the empty expression warning. Ref: https://github.com/curl/curl/commit/5b22e1a#r36458547
* strerror: Add Curl_winapi_strerror for Win API specific errorsJay Satiro2019-12-011-341/+228
| | | | | | | | | | | | | | | - In all code call Curl_winapi_strerror instead of Curl_strerror when the error code is known to be from Windows GetLastError. Curl_strerror prefers CRT error codes (errno) over Windows API error codes (GetLastError) when the two overlap. When we know the error code is from GetLastError it is more accurate to prefer the Windows API error messages. Reported-by: Richard Alcock Fixes https://github.com/curl/curl/issues/4550 Closes https://github.com/curl/curl/pull/4581
* multi: add curl_multi_wakeup()Gergely Nagy2019-11-251-0/+3
| | | | | | | | | | | | This commit adds curl_multi_wakeup() which was previously in the TODO list under the curl_multi_unblock name. On some platforms and with some configurations this feature might not be available or can fail, in these cases a new error code (CURLM_WAKEUP_FAILURE) is returned from curl_multi_wakeup(). Fixes #4418 Closes #4608
* include: make CURLE_HTTP3 use a new error codeDaniel Stenberg2019-11-211-0/+1
| | | | | | | | | To avoid potential issues with error code reuse. Reported-by: Christoph M. Becker Assisted-by: Dan Fandrich Fixes #4601 Closes #4627
* quiche: reject headers in the wrong orderDaniel Stenberg2019-11-121-1/+3
| | | | | | | | Pseudo header MUST come before regular headers or cause an error. Reported-by: Cynthia Coan Fixes #4571 Closes #4584
* strerror: Fix an error looking up some Windows error stringsJay Satiro2019-11-091-2/+4
| | | | | | | | | | | | | | | | | | - Use FORMAT_MESSAGE_IGNORE_INSERTS to ignore format specifiers in Windows error strings. Since we are not in control of the error code we don't know what information may be needed by the error string's format specifiers. Prior to this change Windows API error strings which contain specifiers (think specifiers like similar to printf specifiers) would not be shown. The FormatMessage Windows API call which turns a Windows error code into a string could fail and set error ERROR_INVALID_PARAMETER if that error string contained a format specifier. FormatMessage expects a va_list for the specifiers, unless inserts are ignored in which case no substitution is attempted. Ref: https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353
* vauth: Use CURLE_AUTH_ERROR for auth function errorsJay Satiro2019-08-141-0/+3
| | | | | | | | | | | | | | - Add new error code CURLE_AUTH_ERROR. Prior to this change auth function errors were signaled by CURLE_OUT_OF_MEMORY and CURLE_RECV_ERROR, and neither one was technically correct. Ref: https://github.com/curl/curl/pull/3848 Co-authored-by: Dominik Hölzl Closes https://github.com/curl/curl/pull/3864
* strerror: make the strerror function use local buffersDaniel Stenberg2019-02-261-12/+8
| | | | | | | | | | | | | | | | Instead of using a fixed 256 byte buffer in the connectdata struct. In my build, this reduces the size of the connectdata struct by 11.8%, from 2160 to 1904 bytes with no functionality or performance loss. This also fixes a bug in schannel's Curl_verify_certificate where it called Curl_sspi_strerror when it should have called Curl_strerror for string from GetLastError. the only effect would have been no text or the wrong text being shown for the error. Co-authored-by: Jay Satiro Closes #3612
* snprintf: renamed and we now only use msnprintf()Daniel Stenberg2018-11-231-13/+13
| | | | | | | | | | | The function does not return the same value as snprintf() normally does, so readers may be mislead into thinking the code works differently than it actually does. A different function name makes this easier to detect. Reported-by: Tomas Hoger Assisted-by: Daniel Gustafsson Fixes #3296 Closes #3297
* ssl: deprecate CURLE_SSL_CACERT in favour of a unified error codeHan Han2018-09-061-6/+3
| | | | Long live CURLE_PEER_FAILED_VERIFICATION
* TODO fixed: Detect when called from within callbacksBjörn Stenberg2018-02-151-0/+6
| | | | Closes #2302
* strerror: Preserve Windows error code in some functionsJay Satiro2017-07-111-25/+42
| | | | | | | | | | | This is a follow-up to af02162 which removed (SET_)ERRNO macros. That commit was an earlier draft that I committed by mistake, which was then remedied by a5834e5 and e909de6, and now this commit. With this commit there is now no difference between the current code and the changes that were approved in the final draft. Thanks-to: Max Dymond, Marcel Raad, Daniel Stenberg, Gisle Vanem Ref: https://github.com/curl/curl/pull/1589
* errno: fix non-windows builds after af0216251b94e7Daniel Stenberg2017-07-101-5/+7
|
* curl_setup_once: Remove ERRNO/SET_ERRNO macrosJay Satiro2017-07-101-6/+18
| | | | | | | | | | | | Prior to this change (SET_)ERRNO mapped to GetLastError/SetLastError for Win32 and regular errno otherwise. I reviewed the code and found no justifiable reason for conflating errno on WIN32 with GetLastError/SetLastError. All Win32 CRTs support errno, and any Win32 multithreaded CRT supports thread-local errno. Fixes https://github.com/curl/curl/issues/895 Closes https://github.com/curl/curl/pull/1589
* checksrc: warn for assignments within if() expressionsDaniel Stenberg2016-12-141-8/+12
| | | | | ... they're already frowned upon in our source code style guide, this now enforces the rule harder.
* checksrc: stricter no-space-before-paren enforcementDaniel Stenberg2016-12-131-6/+6
| | | | In order to make the code style more uniform everywhere
* idn: switch to libidn2 use and IDNA2008 supportDaniel Stenberg2016-10-311-79/+2
| | | | | | | CVE-2016-8625 Bug: https://curl.haxx.se/docs/adv_20161102K.html Reported-by: Christian Heimes
* s/cURL/curlDaniel Stenberg2016-10-181-1/+1
| | | | | The tool was never called cURL, only the project. But even so, we have more and more over time switched to just use lower case.
* errors: new alias CURLE_WEIRD_SERVER_REPLY (8)Jay Satiro2016-09-071-2/+2
| | | | | | | | Since we're using CURLE_FTP_WEIRD_SERVER_REPLY in imap, pop3 and smtp as more of a generic "failed to parse" introduce an alias without FTP in the name. Closes https://github.com/curl/curl/pull/975
* lib: include curl_printf.h as one of the last headersDaniel Stenberg2016-04-291-2/+2
| | | | | | | | | | | | | | | | | | | | curl_printf.h defines printf to curl_mprintf, etc. This can cause problems with external headers which may use __attribute__((format(printf, ...))) markers etc. To avoid that they cause problems with system includes, we include curl_printf.h after any system headers. That makes the three last headers to always be, and we keep them in this order: curl_printf.h curl_memory.h memdebug.h None of them include system headers, they all do funny #defines. Reported-by: David Benjamin Fixes #743
* http2: Add handling stream level errorTatsuhiro Tsujikawa2016-04-111-0/+3
| | | | | | | | | | | | | Previously, when a stream was closed with other than NGHTTP2_NO_ERROR by RST_STREAM, underlying TCP connection was dropped. This is undesirable since there may be other streams multiplexed and they are very much fine. This change introduce new error code CURLE_HTTP2_STREAM, which indicates stream error that only affects the relevant stream, and connection should be kept open. The existing CURLE_HTTP2 means connection error in general. Ref: https://github.com/curl/curl/issues/659 Ref: https://github.com/curl/curl/pull/663
* strerror: don't bit shift a signed integerJay Satiro2016-03-311-4/+3
| | | | | Bug: https://github.com/curl/curl/issues/744 Reported-by: Alexis La Goutte
* URLs: change all http:// URLs to https://Daniel Stenberg2016-02-031-1/+1
|
* curl_sspi: fix possibly undefined CRYPT_E_REVOKEDJay Satiro2015-09-101-0/+4
| | | | | Bug: https://github.com/bagder/curl/pull/411 Reported-by: Viktor Szakats
* strerror: Add CRYPT_E_REVOKED to SSPI error stringsJay Satiro2015-07-151-0/+3
|
* strerror: Change SEC_E_ILLEGAL_MESSAGE descriptionJay Satiro2015-05-221-0/+6
| | | | | | | | | Prior to this change the description for SEC_E_ILLEGAL_MESSAGE was OS and language specific, and invariably translated to something not very helpful like: "The message received was unexpected or badly formatted." Bug: https://github.com/bagder/curl/issues/267 Reported-by: Michael Osipov
* checksrc: use space after commaDaniel Stenberg2015-03-171-6/+6
|
* mprintf.h: remove #ifdef CURLDEBUGDaniel Stenberg2015-03-031-4/+1
| | | | | ... and as a consequence, introduce curl_printf.h with that re-define magic instead and make all libcurl code use that instead.
* url: add CURLOPT_SSL_VERIFYSTATUS optionAlessandro Ghedini2015-01-161-1/+4
| | | | | | | | | | This option can be used to enable/disable certificate status verification using the "Certificate Status Request" TLS extension defined in RFC6066 section 8. This also adds the CURLE_SSL_INVALIDCERTSTATUS error, to be used when the certificate status verification fails, and the Curl_ssl_cert_status_request() function, used to check whether the SSL backend supports the status_request extension.
* code cleanup: we prefer 'CURLcode result'Daniel Stenberg2014-10-241-2/+2
| | | | | | | | | | | | | | ... for the local variable name in functions holding the return code. Using the same name universally makes code easier to read and follow. Also, unify code for checking for CURLcode errors with: if(result) or if(!result) instead of if(result == CURLE_OK), if(CURLE_OK == result) or if(result != CURLE_OK)
* Factorize pinned public key code into generic file handling and backend specificPatrick Monnerat2014-10-131-1/+1
|
* SSL: implement public key pinningmoparisthebest2014-10-071-0/+3
| | | | | | | | | | | | Option --pinnedpubkey takes a path to a public key in DER format and only connect if it matches (currently only implemented with OpenSSL). Provides CURLOPT_PINNEDPUBLICKEY for curl_easy_setopt(). Extract a public RSA key from a website like so: openssl s_client -connect google.com:443 2>&1 < /dev/null | \ sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -noout -pubkey \ | openssl rsa -pubin -outform DER > google.com.der
* http2: more and better error checkingDaniel Stenberg2014-07-231-1/+3
| | | | | | | 1 - fixes the warnings when built without http2 support 2 - adds CURLE_HTTP2, a new error code for errors detected by nghttp2 basically when they are about http2 specific things.