1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 2004 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #ifdef HAVE_STRERROR_R
26 # if (!defined(HAVE_POSIX_STRERROR_R) && \
27 !defined(HAVE_GLIBC_STRERROR_R)) || \
28 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
29 # error "strerror_r MUST be either POSIX, glibc style"
33 #include <curl/curl.h>
39 #ifdef USE_WINDOWS_SSPI
40 #include "curl_sspi.h"
44 /* The last 3 #include files should be in this order */
45 #include "curl_printf.h"
46 #include "curl_memory.h"
49 #if defined(WIN32) || defined(_WIN32_WCE)
50 #define PRESERVE_WINDOWS_ERROR_CODE
54 curl_easy_strerror(CURLcode error)
56 #ifndef CURL_DISABLE_VERBOSE_STRINGS
61 case CURLE_UNSUPPORTED_PROTOCOL:
62 return "Unsupported protocol";
64 case CURLE_FAILED_INIT:
65 return "Failed initialization";
67 case CURLE_URL_MALFORMAT:
68 return "URL using bad/illegal format or missing URL";
70 case CURLE_NOT_BUILT_IN:
71 return "A requested feature, protocol or option was not found built-in in"
72 " this libcurl due to a build-time decision.";
74 case CURLE_COULDNT_RESOLVE_PROXY:
75 return "Couldn't resolve proxy name";
77 case CURLE_COULDNT_RESOLVE_HOST:
78 return "Couldn't resolve host name";
80 case CURLE_COULDNT_CONNECT:
81 return "Couldn't connect to server";
83 case CURLE_WEIRD_SERVER_REPLY:
84 return "Weird server reply";
86 case CURLE_REMOTE_ACCESS_DENIED:
87 return "Access denied to remote resource";
89 case CURLE_FTP_ACCEPT_FAILED:
90 return "FTP: The server failed to connect to data port";
92 case CURLE_FTP_ACCEPT_TIMEOUT:
93 return "FTP: Accepting server connect has timed out";
95 case CURLE_FTP_PRET_FAILED:
96 return "FTP: The server did not accept the PRET command.";
98 case CURLE_FTP_WEIRD_PASS_REPLY:
99 return "FTP: unknown PASS reply";
101 case CURLE_FTP_WEIRD_PASV_REPLY:
102 return "FTP: unknown PASV reply";
104 case CURLE_FTP_WEIRD_227_FORMAT:
105 return "FTP: unknown 227 response format";
107 case CURLE_FTP_CANT_GET_HOST:
108 return "FTP: can't figure out the host in the PASV response";
111 return "Error in the HTTP2 framing layer";
113 case CURLE_FTP_COULDNT_SET_TYPE:
114 return "FTP: couldn't set file type";
116 case CURLE_PARTIAL_FILE:
117 return "Transferred a partial file";
119 case CURLE_FTP_COULDNT_RETR_FILE:
120 return "FTP: couldn't retrieve (RETR failed) the specified file";
122 case CURLE_QUOTE_ERROR:
123 return "Quote command returned error";
125 case CURLE_HTTP_RETURNED_ERROR:
126 return "HTTP response code said error";
128 case CURLE_WRITE_ERROR:
129 return "Failed writing received data to disk/application";
131 case CURLE_UPLOAD_FAILED:
132 return "Upload failed (at start/before it took off)";
134 case CURLE_READ_ERROR:
135 return "Failed to open/read local data from file/application";
137 case CURLE_OUT_OF_MEMORY:
138 return "Out of memory";
140 case CURLE_OPERATION_TIMEDOUT:
141 return "Timeout was reached";
143 case CURLE_FTP_PORT_FAILED:
144 return "FTP: command PORT failed";
146 case CURLE_FTP_COULDNT_USE_REST:
147 return "FTP: command REST failed";
149 case CURLE_RANGE_ERROR:
150 return "Requested range was not delivered by the server";
152 case CURLE_HTTP_POST_ERROR:
153 return "Internal problem setting up the POST";
155 case CURLE_SSL_CONNECT_ERROR:
156 return "SSL connect error";
158 case CURLE_BAD_DOWNLOAD_RESUME:
159 return "Couldn't resume download";
161 case CURLE_FILE_COULDNT_READ_FILE:
162 return "Couldn't read a file:// file";
164 case CURLE_LDAP_CANNOT_BIND:
165 return "LDAP: cannot bind";
167 case CURLE_LDAP_SEARCH_FAILED:
168 return "LDAP: search failed";
170 case CURLE_FUNCTION_NOT_FOUND:
171 return "A required function in the library was not found";
173 case CURLE_ABORTED_BY_CALLBACK:
174 return "Operation was aborted by an application callback";
176 case CURLE_BAD_FUNCTION_ARGUMENT:
177 return "A libcurl function was given a bad argument";
179 case CURLE_INTERFACE_FAILED:
180 return "Failed binding local connection end";
182 case CURLE_TOO_MANY_REDIRECTS :
183 return "Number of redirects hit maximum amount";
185 case CURLE_UNKNOWN_OPTION:
186 return "An unknown option was passed in to libcurl";
188 case CURLE_SETOPT_OPTION_SYNTAX :
189 return "Malformed option provided in a setopt";
191 case CURLE_GOT_NOTHING:
192 return "Server returned nothing (no headers, no data)";
194 case CURLE_SSL_ENGINE_NOTFOUND:
195 return "SSL crypto engine not found";
197 case CURLE_SSL_ENGINE_SETFAILED:
198 return "Can not set SSL crypto engine as default";
200 case CURLE_SSL_ENGINE_INITFAILED:
201 return "Failed to initialise SSL crypto engine";
203 case CURLE_SEND_ERROR:
204 return "Failed sending data to the peer";
206 case CURLE_RECV_ERROR:
207 return "Failure when receiving data from the peer";
209 case CURLE_SSL_CERTPROBLEM:
210 return "Problem with the local SSL certificate";
212 case CURLE_SSL_CIPHER:
213 return "Couldn't use specified SSL cipher";
215 case CURLE_PEER_FAILED_VERIFICATION:
216 return "SSL peer certificate or SSH remote key was not OK";
218 case CURLE_SSL_CACERT_BADFILE:
219 return "Problem with the SSL CA cert (path? access rights?)";
221 case CURLE_BAD_CONTENT_ENCODING:
222 return "Unrecognized or bad HTTP Content or Transfer-Encoding";
224 case CURLE_FILESIZE_EXCEEDED:
225 return "Maximum file size exceeded";
227 case CURLE_USE_SSL_FAILED:
228 return "Requested SSL level failed";
230 case CURLE_SSL_SHUTDOWN_FAILED:
231 return "Failed to shut down the SSL connection";
233 case CURLE_SSL_CRL_BADFILE:
234 return "Failed to load CRL file (path? access rights?, format?)";
236 case CURLE_SSL_ISSUER_ERROR:
237 return "Issuer check against peer certificate failed";
239 case CURLE_SEND_FAIL_REWIND:
240 return "Send failed since rewinding of the data stream failed";
242 case CURLE_LOGIN_DENIED:
243 return "Login denied";
245 case CURLE_TFTP_NOTFOUND:
246 return "TFTP: File Not Found";
248 case CURLE_TFTP_PERM:
249 return "TFTP: Access Violation";
251 case CURLE_REMOTE_DISK_FULL:
252 return "Disk full or allocation exceeded";
254 case CURLE_TFTP_ILLEGAL:
255 return "TFTP: Illegal operation";
257 case CURLE_TFTP_UNKNOWNID:
258 return "TFTP: Unknown transfer ID";
260 case CURLE_REMOTE_FILE_EXISTS:
261 return "Remote file already exists";
263 case CURLE_TFTP_NOSUCHUSER:
264 return "TFTP: No such user";
266 case CURLE_CONV_FAILED:
267 return "Conversion failed";
269 case CURLE_REMOTE_FILE_NOT_FOUND:
270 return "Remote file not found";
273 return "Error in the SSH layer";
276 return "Socket not ready for send/recv";
278 case CURLE_RTSP_CSEQ_ERROR:
279 return "RTSP CSeq mismatch or invalid CSeq";
281 case CURLE_RTSP_SESSION_ERROR:
282 return "RTSP session error";
284 case CURLE_FTP_BAD_FILE_LIST:
285 return "Unable to parse FTP file list";
287 case CURLE_CHUNK_FAILED:
288 return "Chunk callback failed";
290 case CURLE_NO_CONNECTION_AVAILABLE:
291 return "The max connection limit is reached";
293 case CURLE_SSL_PINNEDPUBKEYNOTMATCH:
294 return "SSL public key does not match pinned public key";
296 case CURLE_SSL_INVALIDCERTSTATUS:
297 return "SSL server certificate status verification FAILED";
299 case CURLE_HTTP2_STREAM:
300 return "Stream error in the HTTP/2 framing layer";
302 case CURLE_RECURSIVE_API_CALL:
303 return "API function called from within callback";
305 case CURLE_AUTH_ERROR:
306 return "An authentication function returned an error";
309 return "HTTP/3 error";
311 case CURLE_QUIC_CONNECT_ERROR:
312 return "QUIC connection error";
315 return "proxy handshake error";
317 case CURLE_SSL_CLIENTCERT:
318 return "SSL Client Certificate required";
320 /* error codes not used by current libcurl */
321 case CURLE_OBSOLETE20:
322 case CURLE_OBSOLETE24:
323 case CURLE_OBSOLETE29:
324 case CURLE_OBSOLETE32:
325 case CURLE_OBSOLETE40:
326 case CURLE_OBSOLETE44:
327 case CURLE_OBSOLETE46:
328 case CURLE_OBSOLETE50:
329 case CURLE_OBSOLETE51:
330 case CURLE_OBSOLETE57:
331 case CURLE_OBSOLETE62:
332 case CURLE_OBSOLETE76:
337 * By using a switch, gcc -Wall will complain about enum values
338 * which do not appear, helping keep this function up-to-date.
339 * By using gcc -Wall -Werror, you can't forget.
341 * A table would not have the same benefit. Most compilers will
342 * generate code very similar to a table in any case, so there
343 * is little performance gain from a table. And something is broken
344 * for the user's application, anyways, so does it matter how fast
347 * The line number for the error will be near this comment, which
348 * is why it is here, and not at the start of the switch.
350 return "Unknown error";
360 curl_multi_strerror(CURLMcode error)
362 #ifndef CURL_DISABLE_VERBOSE_STRINGS
364 case CURLM_CALL_MULTI_PERFORM:
365 return "Please call curl_multi_perform() soon";
370 case CURLM_BAD_HANDLE:
371 return "Invalid multi handle";
373 case CURLM_BAD_EASY_HANDLE:
374 return "Invalid easy handle";
376 case CURLM_OUT_OF_MEMORY:
377 return "Out of memory";
379 case CURLM_INTERNAL_ERROR:
380 return "Internal error";
382 case CURLM_BAD_SOCKET:
383 return "Invalid socket argument";
385 case CURLM_UNKNOWN_OPTION:
386 return "Unknown option";
388 case CURLM_ADDED_ALREADY:
389 return "The easy handle is already added to a multi handle";
391 case CURLM_RECURSIVE_API_CALL:
392 return "API function called from within callback";
394 case CURLM_WAKEUP_FAILURE:
395 return "Wakeup is unavailable or failed";
397 case CURLM_BAD_FUNCTION_ARGUMENT:
398 return "A libcurl function was given a bad argument";
400 case CURLM_ABORTED_BY_CALLBACK:
401 return "Operation was aborted by an application callback";
407 return "Unknown error";
409 if(error == CURLM_OK)
417 curl_share_strerror(CURLSHcode error)
419 #ifndef CURL_DISABLE_VERBOSE_STRINGS
424 case CURLSHE_BAD_OPTION:
425 return "Unknown share option";
428 return "Share currently in use";
430 case CURLSHE_INVALID:
431 return "Invalid share handle";
434 return "Out of memory";
436 case CURLSHE_NOT_BUILT_IN:
437 return "Feature not enabled in this library";
443 return "CURLSHcode unknown";
445 if(error == CURLSHE_OK)
453 curl_url_strerror(CURLUcode error)
455 #ifndef CURL_DISABLE_VERBOSE_STRINGS
460 case CURLUE_BAD_HANDLE:
461 return "An invalid CURLU pointer was passed as argument";
463 case CURLUE_BAD_PARTPOINTER:
464 return "An invalid 'part' argument was passed as argument";
466 case CURLUE_MALFORMED_INPUT:
467 return "Malformed input to a URL function";
469 case CURLUE_BAD_PORT_NUMBER:
470 return "Port number was not a decimal number between 0 and 65535";
472 case CURLUE_UNSUPPORTED_SCHEME:
473 return "This libcurl build doesn't support the given URL scheme";
475 case CURLUE_URLDECODE:
476 return "URL decode error, most likely because of rubbish in the input";
478 case CURLUE_OUT_OF_MEMORY:
479 return "A memory function failed";
481 case CURLUE_USER_NOT_ALLOWED:
482 return "Credentials was passed in the URL when prohibited";
484 case CURLUE_UNKNOWN_PART:
485 return "An unknown part ID was passed to a URL API function";
487 case CURLUE_NO_SCHEME:
488 return "No scheme part in the URL";
491 return "No user part in the URL";
493 case CURLUE_NO_PASSWORD:
494 return "No password part in the URL";
496 case CURLUE_NO_OPTIONS:
497 return "No options part in the URL";
500 return "No host part in the URL";
503 return "No port part in the URL";
505 case CURLUE_NO_QUERY:
506 return "No query part in the URL";
508 case CURLUE_NO_FRAGMENT:
509 return "No fragment part in the URL";
511 case CURLUE_NO_ZONEID:
512 return "No zoneid part in the URL";
514 case CURLUE_BAD_LOGIN:
515 return "Bad login part";
517 case CURLUE_BAD_IPV6:
518 return "Bad IPv6 address";
520 case CURLUE_BAD_HOSTNAME:
521 return "Bad hostname";
523 case CURLUE_BAD_FILE_URL:
524 return "Bad file:// URL";
526 case CURLUE_BAD_SLASHES:
527 return "Unsupported number of slashes";
529 case CURLUE_BAD_SCHEME:
532 case CURLUE_BAD_PATH:
535 case CURLUE_BAD_FRAGMENT:
536 return "Bad fragment";
538 case CURLUE_BAD_QUERY:
541 case CURLUE_BAD_PASSWORD:
542 return "Bad password";
544 case CURLUE_BAD_USER:
551 return "CURLUcode unknown";
553 if(error == CURLUE_OK)
561 /* This is a helper function for Curl_strerror that converts Winsock error
562 * codes (WSAGetLastError) to error messages.
563 * Returns NULL if no error message was found for error code.
566 get_winsock_error (int err, char *buf, size_t len)
568 #ifndef CURL_DISABLE_VERBOSE_STRINGS
577 #ifdef CURL_DISABLE_VERBOSE_STRINGS
583 p = "Call interrupted";
595 p = "Invalid arguments";
598 p = "Out of file descriptors";
601 p = "Call would block";
605 p = "Blocking call in progress";
608 p = "Descriptor is not a socket";
610 case WSAEDESTADDRREQ:
611 p = "Need destination address";
614 p = "Bad message size";
620 p = "Protocol option is unsupported";
622 case WSAEPROTONOSUPPORT:
623 p = "Protocol is unsupported";
625 case WSAESOCKTNOSUPPORT:
626 p = "Socket is unsupported";
629 p = "Operation not supported";
631 case WSAEAFNOSUPPORT:
632 p = "Address family not supported";
634 case WSAEPFNOSUPPORT:
635 p = "Protocol family not supported";
638 p = "Address already in use";
640 case WSAEADDRNOTAVAIL:
641 p = "Address not available";
647 p = "Network unreachable";
650 p = "Network has been reset";
652 case WSAECONNABORTED:
653 p = "Connection was aborted";
656 p = "Connection was reset";
659 p = "No buffer space";
662 p = "Socket is already connected";
665 p = "Socket is not connected";
668 p = "Socket has been shut down";
670 case WSAETOOMANYREFS:
671 p = "Too many references";
676 case WSAECONNREFUSED:
677 p = "Connection refused";
682 case WSAENAMETOOLONG:
688 case WSAEHOSTUNREACH:
689 p = "Host unreachable";
695 p = "Process limit reached";
698 p = "Too many users";
704 p = "Something is stale";
709 #ifdef WSAEDISCON /* missing in SalfordC! */
714 /* Extended Winsock errors */
716 p = "Winsock library is not ready";
718 case WSANOTINITIALISED:
719 p = "Winsock library not initialised";
721 case WSAVERNOTSUPPORTED:
722 p = "Winsock version not supported";
725 /* getXbyY() errors (already handled in herrmsg):
726 * Authoritative Answer: Host not found */
727 case WSAHOST_NOT_FOUND:
728 p = "Host not found";
731 /* Non-Authoritative: Host not found, or SERVERFAIL */
733 p = "Host not found, try again";
736 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
738 p = "Unrecoverable error in call to nameserver";
741 /* Valid name, no data record of requested type */
743 p = "No data record of requested type";
749 strncpy(buf, p, len);
754 #endif /* USE_WINSOCK */
756 #if defined(WIN32) || defined(_WIN32_WCE)
757 /* This is a helper function for Curl_strerror that converts Windows API error
758 * codes (GetLastError) to error messages.
759 * Returns NULL if no error message was found for error code.
762 get_winapi_error(int err, char *buf, size_t buflen)
773 /* We return the local codepage version of the error string because if it is
774 output to the user's terminal it will likely be with functions which
775 expect the local codepage (eg fprintf, failf, infof).
776 FormatMessageW -> wcstombs is used for Windows CE compatibility. */
777 if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM |
778 FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
779 LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
780 size_t written = wcstombs(buf, wbuf, buflen - 1);
781 if(written != (size_t)-1)
787 /* Truncate multiple lines */
788 p = strchr(buf, '\n');
790 if(p > buf && *(p-1) == '\r')
796 return (*buf ? buf : NULL);
798 #endif /* WIN32 || _WIN32_WCE */
801 * Our thread-safe and smart strerror() replacement.
803 * The 'err' argument passed in to this function MUST be a true errno number
804 * as reported on this system. We do no range checking on the number before
805 * we pass it to the "number-to-message" conversion function and there might
806 * be systems that don't do proper range checking in there themselves.
808 * We don't do range checking (on systems other than Windows) since there is
809 * no good reliable and portable way to do it.
811 * On Windows different types of error codes overlap. This function has an
812 * order of preference when trying to match error codes:
813 * CRT (errno), Winsock (WSAGetLastError), Windows API (GetLastError).
815 * It may be more correct to call one of the variant functions instead:
816 * Call Curl_sspi_strerror if the error code is definitely Windows SSPI.
817 * Call Curl_winapi_strerror if the error code is definitely Windows API.
819 const char *Curl_strerror(int err, char *buf, size_t buflen)
821 #ifdef PRESERVE_WINDOWS_ERROR_CODE
822 DWORD old_win_err = GetLastError();
824 int old_errno = errno;
832 DEBUGASSERT(err >= 0);
838 #if defined(WIN32) || defined(_WIN32_WCE)
840 /* 'sys_nerr' is the maximum errno number, it is not widely portable */
841 if(err >= 0 && err < sys_nerr)
842 strncpy(buf, sys_errlist[err], max);
848 !get_winsock_error(err, buf, max) &&
850 !get_winapi_error((DWORD)err, buf, max))
851 msnprintf(buf, max, "Unknown error %d (%#x)", err, err);
853 #else /* not Windows coming up */
855 #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
857 * The POSIX-style strerror_r() may set errno to ERANGE if insufficient
858 * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated
859 * message string, or EINVAL if 'errnum' is not a valid error number.
861 if(0 != strerror_r(err, buf, max)) {
863 msnprintf(buf, max, "Unknown error %d", err);
865 #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
867 * The glibc-style strerror_r() only *might* use the buffer we pass to
868 * the function, but it always returns the error message as a pointer,
869 * so we must copy that string unconditionally (if non-NULL).
873 char *msg = strerror_r(err, buffer, sizeof(buffer));
875 strncpy(buf, msg, max);
877 msnprintf(buf, max, "Unknown error %d", err);
881 /* !checksrc! disable STRERROR 1 */
882 const char *msg = strerror(err);
884 strncpy(buf, msg, max);
886 msnprintf(buf, max, "Unknown error %d", err);
890 #endif /* end of not Windows */
892 buf[max] = '\0'; /* make sure the string is null-terminated */
894 /* strip trailing '\r\n' or '\n'. */
895 p = strrchr(buf, '\n');
896 if(p && (p - buf) >= 2)
898 p = strrchr(buf, '\r');
899 if(p && (p - buf) >= 1)
902 if(errno != old_errno)
905 #ifdef PRESERVE_WINDOWS_ERROR_CODE
906 if(old_win_err != GetLastError())
907 SetLastError(old_win_err);
914 * Curl_winapi_strerror:
915 * Variant of Curl_strerror if the error code is definitely Windows API.
917 #if defined(WIN32) || defined(_WIN32_WCE)
918 const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
920 #ifdef PRESERVE_WINDOWS_ERROR_CODE
921 DWORD old_win_err = GetLastError();
923 int old_errno = errno;
930 #ifndef CURL_DISABLE_VERBOSE_STRINGS
931 if(!get_winapi_error(err, buf, buflen)) {
932 msnprintf(buf, buflen, "Unknown error %u (0x%08X)", err, err);
936 const char *txt = (err == ERROR_SUCCESS) ? "No error" : "Error";
937 strncpy(buf, txt, buflen);
938 buf[buflen - 1] = '\0';
942 if(errno != old_errno)
945 #ifdef PRESERVE_WINDOWS_ERROR_CODE
946 if(old_win_err != GetLastError())
947 SetLastError(old_win_err);
952 #endif /* WIN32 || _WIN32_WCE */
954 #ifdef USE_WINDOWS_SSPI
956 * Curl_sspi_strerror:
957 * Variant of Curl_strerror if the error code is definitely Windows SSPI.
959 const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
961 #ifdef PRESERVE_WINDOWS_ERROR_CODE
962 DWORD old_win_err = GetLastError();
964 int old_errno = errno;
972 #ifndef CURL_DISABLE_VERBOSE_STRINGS
978 #define SEC2TXT(sec) case sec: txt = #sec; break
979 SEC2TXT(CRYPT_E_REVOKED);
980 SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
981 SEC2TXT(SEC_E_BAD_BINDINGS);
982 SEC2TXT(SEC_E_BAD_PKGID);
983 SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
984 SEC2TXT(SEC_E_CANNOT_INSTALL);
985 SEC2TXT(SEC_E_CANNOT_PACK);
986 SEC2TXT(SEC_E_CERT_EXPIRED);
987 SEC2TXT(SEC_E_CERT_UNKNOWN);
988 SEC2TXT(SEC_E_CERT_WRONG_USAGE);
989 SEC2TXT(SEC_E_CONTEXT_EXPIRED);
990 SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
991 SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
992 SEC2TXT(SEC_E_DECRYPT_FAILURE);
993 SEC2TXT(SEC_E_DELEGATION_POLICY);
994 SEC2TXT(SEC_E_DELEGATION_REQUIRED);
995 SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
996 SEC2TXT(SEC_E_ENCRYPT_FAILURE);
997 SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
998 SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
999 SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
1000 SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
1001 SEC2TXT(SEC_E_INTERNAL_ERROR);
1002 SEC2TXT(SEC_E_INVALID_HANDLE);
1003 SEC2TXT(SEC_E_INVALID_PARAMETER);
1004 SEC2TXT(SEC_E_INVALID_TOKEN);
1005 SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
1006 SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
1007 SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
1008 SEC2TXT(SEC_E_KDC_CERT_REVOKED);
1009 SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
1010 SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
1011 SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
1012 SEC2TXT(SEC_E_LOGON_DENIED);
1013 SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
1014 SEC2TXT(SEC_E_MESSAGE_ALTERED);
1015 SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
1016 SEC2TXT(SEC_E_MUST_BE_KDC);
1017 SEC2TXT(SEC_E_NOT_OWNER);
1018 SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
1019 SEC2TXT(SEC_E_NO_CREDENTIALS);
1020 SEC2TXT(SEC_E_NO_IMPERSONATION);
1021 SEC2TXT(SEC_E_NO_IP_ADDRESSES);
1022 SEC2TXT(SEC_E_NO_KERB_KEY);
1023 SEC2TXT(SEC_E_NO_PA_DATA);
1024 SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
1025 SEC2TXT(SEC_E_NO_TGT_REPLY);
1026 SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
1027 SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
1028 SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
1029 SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
1030 SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
1031 SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
1032 SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
1033 SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
1034 SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
1035 SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
1036 SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
1037 SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
1038 SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
1039 SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
1040 SEC2TXT(SEC_E_TARGET_UNKNOWN);
1041 SEC2TXT(SEC_E_TIME_SKEW);
1042 SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
1043 SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
1044 SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
1045 SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
1046 SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
1047 SEC2TXT(SEC_E_UNTRUSTED_ROOT);
1048 SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
1049 SEC2TXT(SEC_E_WRONG_PRINCIPAL);
1050 SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
1051 SEC2TXT(SEC_I_COMPLETE_NEEDED);
1052 SEC2TXT(SEC_I_CONTEXT_EXPIRED);
1053 SEC2TXT(SEC_I_CONTINUE_NEEDED);
1054 SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
1055 SEC2TXT(SEC_I_LOCAL_LOGON);
1056 SEC2TXT(SEC_I_NO_LSA_CONTEXT);
1057 SEC2TXT(SEC_I_RENEGOTIATE);
1058 SEC2TXT(SEC_I_SIGNATURE_NEEDED);
1060 txt = "Unknown error";
1063 if(err == SEC_E_ILLEGAL_MESSAGE) {
1064 msnprintf(buf, buflen,
1065 "SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
1066 "when a fatal SSL/TLS alert is received (e.g. handshake failed)."
1067 " More detail may be available in the Windows System event log.",
1074 msnprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
1076 if(get_winapi_error(err, msgbuf, sizeof(msgbuf)))
1077 msnprintf(buf, buflen, "%s - %s", txtbuf, msgbuf);
1079 strncpy(buf, txtbuf, buflen);
1080 buf[buflen - 1] = '\0';
1089 strncpy(buf, txt, buflen);
1090 buf[buflen - 1] = '\0';
1093 if(errno != old_errno)
1096 #ifdef PRESERVE_WINDOWS_ERROR_CODE
1097 if(old_win_err != GetLastError())
1098 SetLastError(old_win_err);
1103 #endif /* USE_WINDOWS_SSPI */