1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 2004 - 2015, 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 http://curl.haxx.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_VXWORKS_STRERROR_R)) || \
29 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
30 (defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
31 (defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
32 # error "strerror_r MUST be either POSIX, glibc or vxworks-style"
36 #include <curl/curl.h>
44 #define _MPRINTF_REPLACE /* use our functions only */
45 #include <curl/mprintf.h>
47 #include "curl_memory.h"
48 /* The last #include file should be: */
52 curl_easy_strerror(CURLcode error)
54 #ifndef CURL_DISABLE_VERBOSE_STRINGS
59 case CURLE_UNSUPPORTED_PROTOCOL:
60 return "Unsupported protocol";
62 case CURLE_FAILED_INIT:
63 return "Failed initialization";
65 case CURLE_URL_MALFORMAT:
66 return "URL using bad/illegal format or missing URL";
68 case CURLE_NOT_BUILT_IN:
69 return "A requested feature, protocol or option was not found built-in in"
70 " this libcurl due to a build-time decision.";
72 case CURLE_COULDNT_RESOLVE_PROXY:
73 return "Couldn't resolve proxy name";
75 case CURLE_COULDNT_RESOLVE_HOST:
76 return "Couldn't resolve host name";
78 case CURLE_COULDNT_CONNECT:
79 return "Couldn't connect to server";
81 case CURLE_FTP_WEIRD_SERVER_REPLY:
82 return "FTP: weird server reply";
84 case CURLE_REMOTE_ACCESS_DENIED:
85 return "Access denied to remote resource";
87 case CURLE_FTP_ACCEPT_FAILED:
88 return "FTP: The server failed to connect to data port";
90 case CURLE_FTP_ACCEPT_TIMEOUT:
91 return "FTP: Accepting server connect has timed out";
93 case CURLE_FTP_PRET_FAILED:
94 return "FTP: The server did not accept the PRET command.";
96 case CURLE_FTP_WEIRD_PASS_REPLY:
97 return "FTP: unknown PASS reply";
99 case CURLE_FTP_WEIRD_PASV_REPLY:
100 return "FTP: unknown PASV reply";
102 case CURLE_FTP_WEIRD_227_FORMAT:
103 return "FTP: unknown 227 response format";
105 case CURLE_FTP_CANT_GET_HOST:
106 return "FTP: can't figure out the host in the PASV response";
109 return "Error in the HTTP2 framing layer";
111 case CURLE_FTP_COULDNT_SET_TYPE:
112 return "FTP: couldn't set file type";
114 case CURLE_PARTIAL_FILE:
115 return "Transferred a partial file";
117 case CURLE_FTP_COULDNT_RETR_FILE:
118 return "FTP: couldn't retrieve (RETR failed) the specified file";
120 case CURLE_QUOTE_ERROR:
121 return "Quote command returned error";
123 case CURLE_HTTP_RETURNED_ERROR:
124 return "HTTP response code said error";
126 case CURLE_WRITE_ERROR:
127 return "Failed writing received data to disk/application";
129 case CURLE_UPLOAD_FAILED:
130 return "Upload failed (at start/before it took off)";
132 case CURLE_READ_ERROR:
133 return "Failed to open/read local data from file/application";
135 case CURLE_OUT_OF_MEMORY:
136 return "Out of memory";
138 case CURLE_OPERATION_TIMEDOUT:
139 return "Timeout was reached";
141 case CURLE_FTP_PORT_FAILED:
142 return "FTP: command PORT failed";
144 case CURLE_FTP_COULDNT_USE_REST:
145 return "FTP: command REST failed";
147 case CURLE_RANGE_ERROR:
148 return "Requested range was not delivered by the server";
150 case CURLE_HTTP_POST_ERROR:
151 return "Internal problem setting up the POST";
153 case CURLE_SSL_CONNECT_ERROR:
154 return "SSL connect error";
156 case CURLE_BAD_DOWNLOAD_RESUME:
157 return "Couldn't resume download";
159 case CURLE_FILE_COULDNT_READ_FILE:
160 return "Couldn't read a file:// file";
162 case CURLE_LDAP_CANNOT_BIND:
163 return "LDAP: cannot bind";
165 case CURLE_LDAP_SEARCH_FAILED:
166 return "LDAP: search failed";
168 case CURLE_FUNCTION_NOT_FOUND:
169 return "A required function in the library was not found";
171 case CURLE_ABORTED_BY_CALLBACK:
172 return "Operation was aborted by an application callback";
174 case CURLE_BAD_FUNCTION_ARGUMENT:
175 return "A libcurl function was given a bad argument";
177 case CURLE_INTERFACE_FAILED:
178 return "Failed binding local connection end";
180 case CURLE_TOO_MANY_REDIRECTS :
181 return "Number of redirects hit maximum amount";
183 case CURLE_UNKNOWN_OPTION:
184 return "An unknown option was passed in to libcurl";
186 case CURLE_TELNET_OPTION_SYNTAX :
187 return "Malformed telnet option";
189 case CURLE_PEER_FAILED_VERIFICATION:
190 return "SSL peer certificate or SSH remote key was not OK";
192 case CURLE_GOT_NOTHING:
193 return "Server returned nothing (no headers, no data)";
195 case CURLE_SSL_ENGINE_NOTFOUND:
196 return "SSL crypto engine not found";
198 case CURLE_SSL_ENGINE_SETFAILED:
199 return "Can not set SSL crypto engine as default";
201 case CURLE_SSL_ENGINE_INITFAILED:
202 return "Failed to initialise SSL crypto engine";
204 case CURLE_SEND_ERROR:
205 return "Failed sending data to the peer";
207 case CURLE_RECV_ERROR:
208 return "Failure when receiving data from the peer";
210 case CURLE_SSL_CERTPROBLEM:
211 return "Problem with the local SSL certificate";
213 case CURLE_SSL_CIPHER:
214 return "Couldn't use specified SSL cipher";
216 case CURLE_SSL_CACERT:
217 return "Peer certificate cannot be authenticated with given CA "
220 case CURLE_SSL_CACERT_BADFILE:
221 return "Problem with the SSL CA cert (path? access rights?)";
223 case CURLE_BAD_CONTENT_ENCODING:
224 return "Unrecognized or bad HTTP Content or Transfer-Encoding";
226 case CURLE_LDAP_INVALID_URL:
227 return "Invalid LDAP URL";
229 case CURLE_FILESIZE_EXCEEDED:
230 return "Maximum file size exceeded";
232 case CURLE_USE_SSL_FAILED:
233 return "Requested SSL level failed";
235 case CURLE_SSL_SHUTDOWN_FAILED:
236 return "Failed to shut down the SSL connection";
238 case CURLE_SSL_CRL_BADFILE:
239 return "Failed to load CRL file (path? access rights?, format?)";
241 case CURLE_SSL_ISSUER_ERROR:
242 return "Issuer check against peer certificate failed";
244 case CURLE_SEND_FAIL_REWIND:
245 return "Send failed since rewinding of the data stream failed";
247 case CURLE_LOGIN_DENIED:
248 return "Login denied";
250 case CURLE_TFTP_NOTFOUND:
251 return "TFTP: File Not Found";
253 case CURLE_TFTP_PERM:
254 return "TFTP: Access Violation";
256 case CURLE_REMOTE_DISK_FULL:
257 return "Disk full or allocation exceeded";
259 case CURLE_TFTP_ILLEGAL:
260 return "TFTP: Illegal operation";
262 case CURLE_TFTP_UNKNOWNID:
263 return "TFTP: Unknown transfer ID";
265 case CURLE_REMOTE_FILE_EXISTS:
266 return "Remote file already exists";
268 case CURLE_TFTP_NOSUCHUSER:
269 return "TFTP: No such user";
271 case CURLE_CONV_FAILED:
272 return "Conversion failed";
274 case CURLE_CONV_REQD:
275 return "Caller must register CURLOPT_CONV_ callback options";
277 case CURLE_REMOTE_FILE_NOT_FOUND:
278 return "Remote file not found";
281 return "Error in the SSH layer";
284 return "Socket not ready for send/recv";
286 case CURLE_RTSP_CSEQ_ERROR:
287 return "RTSP CSeq mismatch or invalid CSeq";
289 case CURLE_RTSP_SESSION_ERROR:
290 return "RTSP session error";
292 case CURLE_FTP_BAD_FILE_LIST:
293 return "Unable to parse FTP file list";
295 case CURLE_CHUNK_FAILED:
296 return "Chunk callback failed";
298 case CURLE_NO_CONNECTION_AVAILABLE:
299 return "The max connection limit is reached";
301 case CURLE_SSL_PINNEDPUBKEYNOTMATCH:
302 return "SSL public key does not match pinned public key";
304 case CURLE_SSL_INVALIDCERTSTATUS:
305 return "SSL server certificate status verification FAILED";
307 /* error codes not used by current libcurl */
308 case CURLE_OBSOLETE20:
309 case CURLE_OBSOLETE24:
310 case CURLE_OBSOLETE29:
311 case CURLE_OBSOLETE32:
312 case CURLE_OBSOLETE40:
313 case CURLE_OBSOLETE44:
314 case CURLE_OBSOLETE46:
315 case CURLE_OBSOLETE50:
316 case CURLE_OBSOLETE57:
321 * By using a switch, gcc -Wall will complain about enum values
322 * which do not appear, helping keep this function up-to-date.
323 * By using gcc -Wall -Werror, you can't forget.
325 * A table would not have the same benefit. Most compilers will
326 * generate code very similar to a table in any case, so there
327 * is little performance gain from a table. And something is broken
328 * for the user's application, anyways, so does it matter how fast
331 * The line number for the error will be near this comment, which
332 * is why it is here, and not at the start of the switch.
334 return "Unknown error";
344 curl_multi_strerror(CURLMcode error)
346 #ifndef CURL_DISABLE_VERBOSE_STRINGS
348 case CURLM_CALL_MULTI_PERFORM:
349 return "Please call curl_multi_perform() soon";
354 case CURLM_BAD_HANDLE:
355 return "Invalid multi handle";
357 case CURLM_BAD_EASY_HANDLE:
358 return "Invalid easy handle";
360 case CURLM_OUT_OF_MEMORY:
361 return "Out of memory";
363 case CURLM_INTERNAL_ERROR:
364 return "Internal error";
366 case CURLM_BAD_SOCKET:
367 return "Invalid socket argument";
369 case CURLM_UNKNOWN_OPTION:
370 return "Unknown option";
372 case CURLM_ADDED_ALREADY:
373 return "The easy handle is already added to a multi handle";
379 return "Unknown error";
381 if(error == CURLM_OK)
389 curl_share_strerror(CURLSHcode error)
391 #ifndef CURL_DISABLE_VERBOSE_STRINGS
396 case CURLSHE_BAD_OPTION:
397 return "Unknown share option";
400 return "Share currently in use";
402 case CURLSHE_INVALID:
403 return "Invalid share handle";
406 return "Out of memory";
408 case CURLSHE_NOT_BUILT_IN:
409 return "Feature not enabled in this library";
415 return "CURLSHcode unknown";
417 if(error == CURLSHE_OK)
426 /* This function handles most / all (?) Winsock errors cURL is able to produce.
429 get_winsock_error (int err, char *buf, size_t len)
433 #ifndef CURL_DISABLE_VERBOSE_STRINGS
436 p = "Call interrupted";
448 p = "Invalid arguments";
451 p = "Out of file descriptors";
454 p = "Call would block";
458 p = "Blocking call in progress";
461 p = "Descriptor is not a socket";
463 case WSAEDESTADDRREQ:
464 p = "Need destination address";
467 p = "Bad message size";
473 p = "Protocol option is unsupported";
475 case WSAEPROTONOSUPPORT:
476 p = "Protocol is unsupported";
478 case WSAESOCKTNOSUPPORT:
479 p = "Socket is unsupported";
482 p = "Operation not supported";
484 case WSAEAFNOSUPPORT:
485 p = "Address family not supported";
487 case WSAEPFNOSUPPORT:
488 p = "Protocol family not supported";
491 p = "Address already in use";
493 case WSAEADDRNOTAVAIL:
494 p = "Address not available";
500 p = "Network unreachable";
503 p = "Network has been reset";
505 case WSAECONNABORTED:
506 p = "Connection was aborted";
509 p = "Connection was reset";
512 p = "No buffer space";
515 p = "Socket is already connected";
518 p = "Socket is not connected";
521 p = "Socket has been shut down";
523 case WSAETOOMANYREFS:
524 p = "Too many references";
529 case WSAECONNREFUSED:
530 p = "Connection refused";
535 case WSAENAMETOOLONG:
541 case WSAEHOSTUNREACH:
542 p = "Host unreachable";
548 p = "Process limit reached";
551 p = "Too many users";
557 p = "Something is stale";
562 #ifdef WSAEDISCON /* missing in SalfordC! */
567 /* Extended Winsock errors */
569 p = "Winsock library is not ready";
571 case WSANOTINITIALISED:
572 p = "Winsock library not initialised";
574 case WSAVERNOTSUPPORTED:
575 p = "Winsock version not supported";
578 /* getXbyY() errors (already handled in herrmsg):
579 * Authoritative Answer: Host not found */
580 case WSAHOST_NOT_FOUND:
581 p = "Host not found";
584 /* Non-Authoritative: Host not found, or SERVERFAIL */
586 p = "Host not found, try again";
589 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
591 p = "Unrecoverable error in call to nameserver";
594 /* Valid name, no data record of requested type */
596 p = "No data record of requested type";
608 strncpy (buf, p, len);
612 #endif /* USE_WINSOCK */
615 * Our thread-safe and smart strerror() replacement.
617 * The 'err' argument passed in to this function MUST be a true errno number
618 * as reported on this system. We do no range checking on the number before
619 * we pass it to the "number-to-message" conversion function and there might
620 * be systems that don't do proper range checking in there themselves.
622 * We don't do range checking (on systems other than Windows) since there is
623 * no good reliable and portable way to do it.
625 const char *Curl_strerror(struct connectdata *conn, int err)
629 int old_errno = ERRNO;
632 DEBUGASSERT(err >= 0);
634 buf = conn->syserr_buf;
635 max = sizeof(conn->syserr_buf)-1;
645 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
646 LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL);
647 wcstombs(buf,wbuf,max);
650 /* 'sys_nerr' is the maximum errno number, it is not widely portable */
651 if(err >= 0 && err < sys_nerr)
652 strncpy(buf, strerror(err), max);
654 if(!get_winsock_error(err, buf, max) &&
655 !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
656 LANG_NEUTRAL, buf, (DWORD)max, NULL))
657 snprintf(buf, max, "Unknown error %d (%#x)", err, err);
661 #else /* not USE_WINSOCK coming up */
663 #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
665 * The POSIX-style strerror_r() may set errno to ERANGE if insufficient
666 * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated
667 * message string, or EINVAL if 'errnum' is not a valid error number.
669 if(0 != strerror_r(err, buf, max)) {
671 snprintf(buf, max, "Unknown error %d", err);
673 #elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
675 * The glibc-style strerror_r() only *might* use the buffer we pass to
676 * the function, but it always returns the error message as a pointer,
677 * so we must copy that string unconditionally (if non-NULL).
681 char *msg = strerror_r(err, buffer, sizeof(buffer));
683 strncpy(buf, msg, max);
685 snprintf(buf, max, "Unknown error %d", err);
687 #elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
689 * The vxworks-style strerror_r() does use the buffer we pass to the function.
690 * The buffer size should be at least NAME_MAX (256)
694 if(OK == strerror_r(err, buffer))
695 strncpy(buf, buffer, max);
697 snprintf(buf, max, "Unknown error %d", err);
701 char *msg = strerror(err);
703 strncpy(buf, msg, max);
705 snprintf(buf, max, "Unknown error %d", err);
709 #endif /* end of ! USE_WINSOCK */
711 buf[max] = '\0'; /* make sure the string is zero terminated */
713 /* strip trailing '\r\n' or '\n'. */
714 if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
716 if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
719 if(old_errno != ERRNO)
720 SET_ERRNO(old_errno);
727 * Return error-string for libidn status as returned from idna_to_ascii_lz().
729 const char *Curl_idn_strerror (struct connectdata *conn, int err)
731 #ifdef HAVE_IDNA_STRERROR
733 return idna_strerror((Idna_rc) err);
741 buf = conn->syserr_buf;
742 max = sizeof(conn->syserr_buf)-1;
745 #ifndef CURL_DISABLE_VERBOSE_STRINGS
746 switch ((Idna_rc)err) {
750 case IDNA_STRINGPREP_ERROR:
751 str = "Error in string preparation";
753 case IDNA_PUNYCODE_ERROR:
754 str = "Error in Punycode operation";
756 case IDNA_CONTAINS_NON_LDH:
757 str = "Illegal ASCII characters";
759 case IDNA_CONTAINS_MINUS:
760 str = "Contains minus";
762 case IDNA_INVALID_LENGTH:
763 str = "Invalid output length";
765 case IDNA_NO_ACE_PREFIX:
766 str = "No ACE prefix (\"xn--\")";
768 case IDNA_ROUNDTRIP_VERIFY_ERROR:
769 str = "Round trip verify error";
771 case IDNA_CONTAINS_ACE_PREFIX:
772 str = "Already have ACE prefix (\"xn--\")";
774 case IDNA_ICONV_ERROR:
775 str = "Locale conversion failed";
777 case IDNA_MALLOC_ERROR:
778 str = "Allocation failed";
780 case IDNA_DLOPEN_ERROR:
781 str = "dlopen() error";
784 snprintf(buf, max, "error %d", err);
789 if((Idna_rc)err == IDNA_SUCCESS)
795 strncpy(buf, str, max);
800 #endif /* USE_LIBIDN */
802 #ifdef USE_WINDOWS_SSPI
803 const char *Curl_sspi_strerror (struct connectdata *conn, int err)
805 #ifndef CURL_DISABLE_VERBOSE_STRINGS
807 char msgbuf[sizeof(conn->syserr_buf)];
808 char *p, *str, *msg = NULL;
809 bool msg_formatted = FALSE;
818 outbuf = conn->syserr_buf;
819 outmax = sizeof(conn->syserr_buf)-1;
822 #ifndef CURL_DISABLE_VERBOSE_STRINGS
830 case SEC_E_ALGORITHM_MISMATCH:
831 txt = "SEC_E_ALGORITHM_MISMATCH";
833 case SEC_E_BAD_BINDINGS:
834 txt = "SEC_E_BAD_BINDINGS";
836 case SEC_E_BAD_PKGID:
837 txt = "SEC_E_BAD_PKGID";
839 case SEC_E_BUFFER_TOO_SMALL:
840 txt = "SEC_E_BUFFER_TOO_SMALL";
842 case SEC_E_CANNOT_INSTALL:
843 txt = "SEC_E_CANNOT_INSTALL";
845 case SEC_E_CANNOT_PACK:
846 txt = "SEC_E_CANNOT_PACK";
848 case SEC_E_CERT_EXPIRED:
849 txt = "SEC_E_CERT_EXPIRED";
851 case SEC_E_CERT_UNKNOWN:
852 txt = "SEC_E_CERT_UNKNOWN";
854 case SEC_E_CERT_WRONG_USAGE:
855 txt = "SEC_E_CERT_WRONG_USAGE";
857 case SEC_E_CONTEXT_EXPIRED:
858 txt = "SEC_E_CONTEXT_EXPIRED";
860 case SEC_E_CROSSREALM_DELEGATION_FAILURE:
861 txt = "SEC_E_CROSSREALM_DELEGATION_FAILURE";
863 case SEC_E_CRYPTO_SYSTEM_INVALID:
864 txt = "SEC_E_CRYPTO_SYSTEM_INVALID";
866 case SEC_E_DECRYPT_FAILURE:
867 txt = "SEC_E_DECRYPT_FAILURE";
869 case SEC_E_DELEGATION_POLICY:
870 txt = "SEC_E_DELEGATION_POLICY";
872 case SEC_E_DELEGATION_REQUIRED:
873 txt = "SEC_E_DELEGATION_REQUIRED";
875 case SEC_E_DOWNGRADE_DETECTED:
876 txt = "SEC_E_DOWNGRADE_DETECTED";
878 case SEC_E_ENCRYPT_FAILURE:
879 txt = "SEC_E_ENCRYPT_FAILURE";
881 case SEC_E_ILLEGAL_MESSAGE:
882 txt = "SEC_E_ILLEGAL_MESSAGE";
884 case SEC_E_INCOMPLETE_CREDENTIALS:
885 txt = "SEC_E_INCOMPLETE_CREDENTIALS";
887 case SEC_E_INCOMPLETE_MESSAGE:
888 txt = "SEC_E_INCOMPLETE_MESSAGE";
890 case SEC_E_INSUFFICIENT_MEMORY:
891 txt = "SEC_E_INSUFFICIENT_MEMORY";
893 case SEC_E_INTERNAL_ERROR:
894 txt = "SEC_E_INTERNAL_ERROR";
896 case SEC_E_INVALID_HANDLE:
897 txt = "SEC_E_INVALID_HANDLE";
899 case SEC_E_INVALID_PARAMETER:
900 txt = "SEC_E_INVALID_PARAMETER";
902 case SEC_E_INVALID_TOKEN:
903 txt = "SEC_E_INVALID_TOKEN";
905 case SEC_E_ISSUING_CA_UNTRUSTED:
906 txt = "SEC_E_ISSUING_CA_UNTRUSTED";
908 case SEC_E_ISSUING_CA_UNTRUSTED_KDC:
909 txt = "SEC_E_ISSUING_CA_UNTRUSTED_KDC";
911 case SEC_E_KDC_CERT_EXPIRED:
912 txt = "SEC_E_KDC_CERT_EXPIRED";
914 case SEC_E_KDC_CERT_REVOKED:
915 txt = "SEC_E_KDC_CERT_REVOKED";
917 case SEC_E_KDC_INVALID_REQUEST:
918 txt = "SEC_E_KDC_INVALID_REQUEST";
920 case SEC_E_KDC_UNABLE_TO_REFER:
921 txt = "SEC_E_KDC_UNABLE_TO_REFER";
923 case SEC_E_KDC_UNKNOWN_ETYPE:
924 txt = "SEC_E_KDC_UNKNOWN_ETYPE";
926 case SEC_E_LOGON_DENIED:
927 txt = "SEC_E_LOGON_DENIED";
929 case SEC_E_MAX_REFERRALS_EXCEEDED:
930 txt = "SEC_E_MAX_REFERRALS_EXCEEDED";
932 case SEC_E_MESSAGE_ALTERED:
933 txt = "SEC_E_MESSAGE_ALTERED";
935 case SEC_E_MULTIPLE_ACCOUNTS:
936 txt = "SEC_E_MULTIPLE_ACCOUNTS";
938 case SEC_E_MUST_BE_KDC:
939 txt = "SEC_E_MUST_BE_KDC";
941 case SEC_E_NOT_OWNER:
942 txt = "SEC_E_NOT_OWNER";
944 case SEC_E_NO_AUTHENTICATING_AUTHORITY:
945 txt = "SEC_E_NO_AUTHENTICATING_AUTHORITY";
947 case SEC_E_NO_CREDENTIALS:
948 txt = "SEC_E_NO_CREDENTIALS";
950 case SEC_E_NO_IMPERSONATION:
951 txt = "SEC_E_NO_IMPERSONATION";
953 case SEC_E_NO_IP_ADDRESSES:
954 txt = "SEC_E_NO_IP_ADDRESSES";
956 case SEC_E_NO_KERB_KEY:
957 txt = "SEC_E_NO_KERB_KEY";
959 case SEC_E_NO_PA_DATA:
960 txt = "SEC_E_NO_PA_DATA";
962 case SEC_E_NO_S4U_PROT_SUPPORT:
963 txt = "SEC_E_NO_S4U_PROT_SUPPORT";
965 case SEC_E_NO_TGT_REPLY:
966 txt = "SEC_E_NO_TGT_REPLY";
968 case SEC_E_OUT_OF_SEQUENCE:
969 txt = "SEC_E_OUT_OF_SEQUENCE";
971 case SEC_E_PKINIT_CLIENT_FAILURE:
972 txt = "SEC_E_PKINIT_CLIENT_FAILURE";
974 case SEC_E_PKINIT_NAME_MISMATCH:
975 txt = "SEC_E_PKINIT_NAME_MISMATCH";
977 case SEC_E_POLICY_NLTM_ONLY:
978 txt = "SEC_E_POLICY_NLTM_ONLY";
980 case SEC_E_QOP_NOT_SUPPORTED:
981 txt = "SEC_E_QOP_NOT_SUPPORTED";
983 case SEC_E_REVOCATION_OFFLINE_C:
984 txt = "SEC_E_REVOCATION_OFFLINE_C";
986 case SEC_E_REVOCATION_OFFLINE_KDC:
987 txt = "SEC_E_REVOCATION_OFFLINE_KDC";
989 case SEC_E_SECPKG_NOT_FOUND:
990 txt = "SEC_E_SECPKG_NOT_FOUND";
992 case SEC_E_SECURITY_QOS_FAILED:
993 txt = "SEC_E_SECURITY_QOS_FAILED";
995 case SEC_E_SHUTDOWN_IN_PROGRESS:
996 txt = "SEC_E_SHUTDOWN_IN_PROGRESS";
998 case SEC_E_SMARTCARD_CERT_EXPIRED:
999 txt = "SEC_E_SMARTCARD_CERT_EXPIRED";
1001 case SEC_E_SMARTCARD_CERT_REVOKED:
1002 txt = "SEC_E_SMARTCARD_CERT_REVOKED";
1004 case SEC_E_SMARTCARD_LOGON_REQUIRED:
1005 txt = "SEC_E_SMARTCARD_LOGON_REQUIRED";
1007 case SEC_E_STRONG_CRYPTO_NOT_SUPPORTED:
1008 txt = "SEC_E_STRONG_CRYPTO_NOT_SUPPORTED";
1010 case SEC_E_TARGET_UNKNOWN:
1011 txt = "SEC_E_TARGET_UNKNOWN";
1013 case SEC_E_TIME_SKEW:
1014 txt = "SEC_E_TIME_SKEW";
1016 case SEC_E_TOO_MANY_PRINCIPALS:
1017 txt = "SEC_E_TOO_MANY_PRINCIPALS";
1019 case SEC_E_UNFINISHED_CONTEXT_DELETED:
1020 txt = "SEC_E_UNFINISHED_CONTEXT_DELETED";
1022 case SEC_E_UNKNOWN_CREDENTIALS:
1023 txt = "SEC_E_UNKNOWN_CREDENTIALS";
1025 case SEC_E_UNSUPPORTED_FUNCTION:
1026 txt = "SEC_E_UNSUPPORTED_FUNCTION";
1028 case SEC_E_UNSUPPORTED_PREAUTH:
1029 txt = "SEC_E_UNSUPPORTED_PREAUTH";
1031 case SEC_E_UNTRUSTED_ROOT:
1032 txt = "SEC_E_UNTRUSTED_ROOT";
1034 case SEC_E_WRONG_CREDENTIAL_HANDLE:
1035 txt = "SEC_E_WRONG_CREDENTIAL_HANDLE";
1037 case SEC_E_WRONG_PRINCIPAL:
1038 txt = "SEC_E_WRONG_PRINCIPAL";
1040 case SEC_I_COMPLETE_AND_CONTINUE:
1041 txt = "SEC_I_COMPLETE_AND_CONTINUE";
1043 case SEC_I_COMPLETE_NEEDED:
1044 txt = "SEC_I_COMPLETE_NEEDED";
1046 case SEC_I_CONTEXT_EXPIRED:
1047 txt = "SEC_I_CONTEXT_EXPIRED";
1049 case SEC_I_CONTINUE_NEEDED:
1050 txt = "SEC_I_CONTINUE_NEEDED";
1052 case SEC_I_INCOMPLETE_CREDENTIALS:
1053 txt = "SEC_I_INCOMPLETE_CREDENTIALS";
1055 case SEC_I_LOCAL_LOGON:
1056 txt = "SEC_I_LOCAL_LOGON";
1058 case SEC_I_NO_LSA_CONTEXT:
1059 txt = "SEC_I_NO_LSA_CONTEXT";
1061 case SEC_I_RENEGOTIATE:
1062 txt = "SEC_I_RENEGOTIATE";
1064 case SEC_I_SIGNATURE_NEEDED:
1065 txt = "SEC_I_SIGNATURE_NEEDED";
1068 txt = "Unknown error";
1072 strncpy(outbuf, txt, outmax);
1075 snprintf(txtbuf, sizeof(txtbuf), "%s (0x%04X%04X)",
1076 txt, (err >> 16) & 0xffff, err & 0xffff);
1077 txtbuf[sizeof(txtbuf)-1] = '\0';
1084 if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
1085 FORMAT_MESSAGE_IGNORE_INSERTS,
1086 NULL, err, LANG_NEUTRAL,
1087 wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
1088 wcstombs(msgbuf,wbuf,sizeof(msgbuf)-1);
1089 msg_formatted = TRUE;
1093 if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
1094 FORMAT_MESSAGE_IGNORE_INSERTS,
1095 NULL, err, LANG_NEUTRAL,
1096 msgbuf, sizeof(msgbuf)-1, NULL)) {
1097 msg_formatted = TRUE;
1101 msgbuf[sizeof(msgbuf)-1] = '\0';
1102 /* strip trailing '\r\n' or '\n' */
1103 if((p = strrchr(msgbuf,'\n')) != NULL && (p - msgbuf) >= 2)
1105 if((p = strrchr(msgbuf,'\r')) != NULL && (p - msgbuf) >= 1)
1110 snprintf(outbuf, outmax, "%s - %s", str, msg);
1112 strncpy(outbuf, str, outmax);
1115 if(old_errno != ERRNO)
1116 SET_ERRNO(old_errno);
1125 strncpy(outbuf, txt, outmax);
1129 outbuf[outmax] = '\0';
1133 #endif /* USE_WINDOWS_SSPI */