Coverage Report

Created: 2025-10-10 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/PROJ/curl/lib/strerror.c
Line
Count
Source
1
/***************************************************************************
2
 *                                  _   _ ____  _
3
 *  Project                     ___| | | |  _ \| |
4
 *                             / __| | | | |_) | |
5
 *                            | (__| |_| |  _ <| |___
6
 *                             \___|\___/|_| \_\_____|
7
 *
8
 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9
 *
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.
13
 *
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.
17
 *
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
 * KIND, either express or implied.
20
 *
21
 * SPDX-License-Identifier: curl
22
 *
23
 ***************************************************************************/
24
25
#include "curl_setup.h"
26
27
#include <curl/curl.h>
28
#include <curl/mprintf.h>
29
30
#ifdef USE_WINDOWS_SSPI
31
#include "curl_sspi.h"
32
#endif
33
34
#include "curlx/winapi.h"
35
#include "strerror.h"
36
37
/* The last 2 #include files should be in this order */
38
#include "curl_memory.h"
39
#include "memdebug.h"
40
41
const char *
42
curl_easy_strerror(CURLcode error)
43
0
{
44
0
#ifndef CURL_DISABLE_VERBOSE_STRINGS
45
0
  switch(error) {
46
0
  case CURLE_OK:
47
0
    return "No error";
48
49
0
  case CURLE_UNSUPPORTED_PROTOCOL:
50
0
    return "Unsupported protocol";
51
52
0
  case CURLE_FAILED_INIT:
53
0
    return "Failed initialization";
54
55
0
  case CURLE_URL_MALFORMAT:
56
0
    return "URL using bad/illegal format or missing URL";
57
58
0
  case CURLE_NOT_BUILT_IN:
59
0
    return "A requested feature, protocol or option was not found built-in in"
60
0
      " this libcurl due to a build-time decision.";
61
62
0
  case CURLE_COULDNT_RESOLVE_PROXY:
63
0
    return "Could not resolve proxy name";
64
65
0
  case CURLE_COULDNT_RESOLVE_HOST:
66
0
    return "Could not resolve hostname";
67
68
0
  case CURLE_COULDNT_CONNECT:
69
0
    return "Could not connect to server";
70
71
0
  case CURLE_WEIRD_SERVER_REPLY:
72
0
    return "Weird server reply";
73
74
0
  case CURLE_REMOTE_ACCESS_DENIED:
75
0
    return "Access denied to remote resource";
76
77
0
  case CURLE_FTP_ACCEPT_FAILED:
78
0
    return "FTP: The server failed to connect to data port";
79
80
0
  case CURLE_FTP_ACCEPT_TIMEOUT:
81
0
    return "FTP: Accepting server connect has timed out";
82
83
0
  case CURLE_FTP_PRET_FAILED:
84
0
    return "FTP: The server did not accept the PRET command.";
85
86
0
  case CURLE_FTP_WEIRD_PASS_REPLY:
87
0
    return "FTP: unknown PASS reply";
88
89
0
  case CURLE_FTP_WEIRD_PASV_REPLY:
90
0
    return "FTP: unknown PASV reply";
91
92
0
  case CURLE_FTP_WEIRD_227_FORMAT:
93
0
    return "FTP: unknown 227 response format";
94
95
0
  case CURLE_FTP_CANT_GET_HOST:
96
0
    return "FTP: cannot figure out the host in the PASV response";
97
98
0
  case CURLE_HTTP2:
99
0
    return "Error in the HTTP2 framing layer";
100
101
0
  case CURLE_FTP_COULDNT_SET_TYPE:
102
0
    return "FTP: could not set file type";
103
104
0
  case CURLE_PARTIAL_FILE:
105
0
    return "Transferred a partial file";
106
107
0
  case CURLE_FTP_COULDNT_RETR_FILE:
108
0
    return "FTP: could not retrieve (RETR failed) the specified file";
109
110
0
  case CURLE_QUOTE_ERROR:
111
0
    return "Quote command returned error";
112
113
0
  case CURLE_HTTP_RETURNED_ERROR:
114
0
    return "HTTP response code said error";
115
116
0
  case CURLE_WRITE_ERROR:
117
0
    return "Failed writing received data to disk/application";
118
119
0
  case CURLE_UPLOAD_FAILED:
120
0
    return "Upload failed (at start/before it took off)";
121
122
0
  case CURLE_READ_ERROR:
123
0
    return "Failed to open/read local data from file/application";
124
125
0
  case CURLE_OUT_OF_MEMORY:
126
0
    return "Out of memory";
127
128
0
  case CURLE_OPERATION_TIMEDOUT:
129
0
    return "Timeout was reached";
130
131
0
  case CURLE_FTP_PORT_FAILED:
132
0
    return "FTP: command PORT failed";
133
134
0
  case CURLE_FTP_COULDNT_USE_REST:
135
0
    return "FTP: command REST failed";
136
137
0
  case CURLE_RANGE_ERROR:
138
0
    return "Requested range was not delivered by the server";
139
140
0
  case CURLE_SSL_CONNECT_ERROR:
141
0
    return "SSL connect error";
142
143
0
  case CURLE_BAD_DOWNLOAD_RESUME:
144
0
    return "Could not resume download";
145
146
0
  case CURLE_FILE_COULDNT_READ_FILE:
147
0
    return "Could not read a file:// file";
148
149
0
  case CURLE_LDAP_CANNOT_BIND:
150
0
    return "LDAP: cannot bind";
151
152
0
  case CURLE_LDAP_SEARCH_FAILED:
153
0
    return "LDAP: search failed";
154
155
0
  case CURLE_ABORTED_BY_CALLBACK:
156
0
    return "Operation was aborted by an application callback";
157
158
0
  case CURLE_BAD_FUNCTION_ARGUMENT:
159
0
    return "A libcurl function was given a bad argument";
160
161
0
  case CURLE_INTERFACE_FAILED:
162
0
    return "Failed binding local connection end";
163
164
0
  case CURLE_TOO_MANY_REDIRECTS:
165
0
    return "Number of redirects hit maximum amount";
166
167
0
  case CURLE_UNKNOWN_OPTION:
168
0
    return "An unknown option was passed in to libcurl";
169
170
0
  case CURLE_SETOPT_OPTION_SYNTAX:
171
0
    return "Malformed option provided in a setopt";
172
173
0
  case CURLE_GOT_NOTHING:
174
0
    return "Server returned nothing (no headers, no data)";
175
176
0
  case CURLE_SSL_ENGINE_NOTFOUND:
177
0
    return "SSL crypto engine not found";
178
179
0
  case CURLE_SSL_ENGINE_SETFAILED:
180
0
    return "Can not set SSL crypto engine as default";
181
182
0
  case CURLE_SSL_ENGINE_INITFAILED:
183
0
    return "Failed to initialise SSL crypto engine";
184
185
0
  case CURLE_SEND_ERROR:
186
0
    return "Failed sending data to the peer";
187
188
0
  case CURLE_RECV_ERROR:
189
0
    return "Failure when receiving data from the peer";
190
191
0
  case CURLE_SSL_CERTPROBLEM:
192
0
    return "Problem with the local SSL certificate";
193
194
0
  case CURLE_SSL_CIPHER:
195
0
    return "Could not use specified SSL cipher";
196
197
0
  case CURLE_PEER_FAILED_VERIFICATION:
198
0
    return "SSL peer certificate or SSH remote key was not OK";
199
200
0
  case CURLE_SSL_CACERT_BADFILE:
201
0
    return "Problem with the SSL CA cert (path? access rights?)";
202
203
0
  case CURLE_BAD_CONTENT_ENCODING:
204
0
    return "Unrecognized or bad HTTP Content or Transfer-Encoding";
205
206
0
  case CURLE_FILESIZE_EXCEEDED:
207
0
    return "Maximum file size exceeded";
208
209
0
  case CURLE_USE_SSL_FAILED:
210
0
    return "Requested SSL level failed";
211
212
0
  case CURLE_SSL_SHUTDOWN_FAILED:
213
0
    return "Failed to shut down the SSL connection";
214
215
0
  case CURLE_SSL_CRL_BADFILE:
216
0
    return "Failed to load CRL file (path? access rights?, format?)";
217
218
0
  case CURLE_SSL_ISSUER_ERROR:
219
0
    return "Issuer check against peer certificate failed";
220
221
0
  case CURLE_SEND_FAIL_REWIND:
222
0
    return "Send failed since rewinding of the data stream failed";
223
224
0
  case CURLE_LOGIN_DENIED:
225
0
    return "Login denied";
226
227
0
  case CURLE_TFTP_NOTFOUND:
228
0
    return "TFTP: File Not Found";
229
230
0
  case CURLE_TFTP_PERM:
231
0
    return "TFTP: Access Violation";
232
233
0
  case CURLE_REMOTE_DISK_FULL:
234
0
    return "Disk full or allocation exceeded";
235
236
0
  case CURLE_TFTP_ILLEGAL:
237
0
    return "TFTP: Illegal operation";
238
239
0
  case CURLE_TFTP_UNKNOWNID:
240
0
    return "TFTP: Unknown transfer ID";
241
242
0
  case CURLE_REMOTE_FILE_EXISTS:
243
0
    return "Remote file already exists";
244
245
0
  case CURLE_TFTP_NOSUCHUSER:
246
0
    return "TFTP: No such user";
247
248
0
  case CURLE_REMOTE_FILE_NOT_FOUND:
249
0
    return "Remote file not found";
250
251
0
  case CURLE_SSH:
252
0
    return "Error in the SSH layer";
253
254
0
  case CURLE_AGAIN:
255
0
    return "Socket not ready for send/recv";
256
257
0
  case CURLE_RTSP_CSEQ_ERROR:
258
0
    return "RTSP CSeq mismatch or invalid CSeq";
259
260
0
  case CURLE_RTSP_SESSION_ERROR:
261
0
    return "RTSP session error";
262
263
0
  case CURLE_FTP_BAD_FILE_LIST:
264
0
    return "Unable to parse FTP file list";
265
266
0
  case CURLE_CHUNK_FAILED:
267
0
    return "Chunk callback failed";
268
269
0
  case CURLE_NO_CONNECTION_AVAILABLE:
270
0
    return "The max connection limit is reached";
271
272
0
  case CURLE_SSL_PINNEDPUBKEYNOTMATCH:
273
0
    return "SSL public key does not match pinned public key";
274
275
0
  case CURLE_SSL_INVALIDCERTSTATUS:
276
0
    return "SSL server certificate status verification FAILED";
277
278
0
  case CURLE_HTTP2_STREAM:
279
0
    return "Stream error in the HTTP/2 framing layer";
280
281
0
  case CURLE_RECURSIVE_API_CALL:
282
0
    return "API function called from within callback";
283
284
0
  case CURLE_AUTH_ERROR:
285
0
    return "An authentication function returned an error";
286
287
0
  case CURLE_HTTP3:
288
0
    return "HTTP/3 error";
289
290
0
  case CURLE_QUIC_CONNECT_ERROR:
291
0
    return "QUIC connection error";
292
293
0
  case CURLE_PROXY:
294
0
    return "proxy handshake error";
295
296
0
  case CURLE_SSL_CLIENTCERT:
297
0
    return "SSL Client Certificate required";
298
299
0
  case CURLE_UNRECOVERABLE_POLL:
300
0
    return "Unrecoverable error in select/poll";
301
302
0
  case CURLE_TOO_LARGE:
303
0
    return "A value or data field grew larger than allowed";
304
305
0
  case CURLE_ECH_REQUIRED:
306
0
    return "ECH attempted but failed";
307
308
    /* error codes not used by current libcurl */
309
0
  default:
310
0
    break;
311
0
  }
312
  /*
313
   * By using a switch, gcc -Wall will complain about enum values
314
   * which do not appear, helping keep this function up-to-date.
315
   * By using gcc -Wall -Werror, you cannot forget.
316
   *
317
   * A table would not have the same benefit. Most compilers will generate
318
   * code similar to a table in any case, so there is little performance gain
319
   * from a table. Something is broken for the user's application, anyways, so
320
   * does it matter how fast it _does not_ work?
321
   *
322
   * The line number for the error will be near this comment, which is why it
323
   * is here, and not at the start of the switch.
324
   */
325
0
  return "Unknown error";
326
#else
327
  if(!error)
328
    return "No error";
329
  else
330
    return "Error";
331
#endif
332
0
}
333
334
const char *
335
curl_multi_strerror(CURLMcode error)
336
0
{
337
0
#ifndef CURL_DISABLE_VERBOSE_STRINGS
338
0
  switch(error) {
339
0
  case CURLM_CALL_MULTI_PERFORM:
340
0
    return "Please call curl_multi_perform() soon";
341
342
0
  case CURLM_OK:
343
0
    return "No error";
344
345
0
  case CURLM_BAD_HANDLE:
346
0
    return "Invalid multi handle";
347
348
0
  case CURLM_BAD_EASY_HANDLE:
349
0
    return "Invalid easy handle";
350
351
0
  case CURLM_OUT_OF_MEMORY:
352
0
    return "Out of memory";
353
354
0
  case CURLM_INTERNAL_ERROR:
355
0
    return "Internal error";
356
357
0
  case CURLM_BAD_SOCKET:
358
0
    return "Invalid socket argument";
359
360
0
  case CURLM_UNKNOWN_OPTION:
361
0
    return "Unknown option";
362
363
0
  case CURLM_ADDED_ALREADY:
364
0
    return "The easy handle is already added to a multi handle";
365
366
0
  case CURLM_RECURSIVE_API_CALL:
367
0
    return "API function called from within callback";
368
369
0
  case CURLM_WAKEUP_FAILURE:
370
0
    return "Wakeup is unavailable or failed";
371
372
0
  case CURLM_BAD_FUNCTION_ARGUMENT:
373
0
    return "A libcurl function was given a bad argument";
374
375
0
  case CURLM_ABORTED_BY_CALLBACK:
376
0
    return "Operation was aborted by an application callback";
377
378
0
  case CURLM_UNRECOVERABLE_POLL:
379
0
    return "Unrecoverable error in select/poll";
380
381
0
  case CURLM_LAST:
382
0
    break;
383
0
  }
384
385
0
  return "Unknown error";
386
#else
387
  if(error == CURLM_OK)
388
    return "No error";
389
  else
390
    return "Error";
391
#endif
392
0
}
393
394
const char *
395
curl_share_strerror(CURLSHcode error)
396
0
{
397
0
#ifndef CURL_DISABLE_VERBOSE_STRINGS
398
0
  switch(error) {
399
0
  case CURLSHE_OK:
400
0
    return "No error";
401
402
0
  case CURLSHE_BAD_OPTION:
403
0
    return "Unknown share option";
404
405
0
  case CURLSHE_IN_USE:
406
0
    return "Share currently in use";
407
408
0
  case CURLSHE_INVALID:
409
0
    return "Invalid share handle";
410
411
0
  case CURLSHE_NOMEM:
412
0
    return "Out of memory";
413
414
0
  case CURLSHE_NOT_BUILT_IN:
415
0
    return "Feature not enabled in this library";
416
417
0
  case CURLSHE_LAST:
418
0
    break;
419
0
  }
420
421
0
  return "CURLSHcode unknown";
422
#else
423
  if(error == CURLSHE_OK)
424
    return "No error";
425
  else
426
    return "Error";
427
#endif
428
0
}
429
430
const char *
431
curl_url_strerror(CURLUcode error)
432
0
{
433
0
#ifndef CURL_DISABLE_VERBOSE_STRINGS
434
0
  switch(error) {
435
0
  case CURLUE_OK:
436
0
    return "No error";
437
438
0
  case CURLUE_BAD_HANDLE:
439
0
    return "An invalid CURLU pointer was passed as argument";
440
441
0
  case CURLUE_BAD_PARTPOINTER:
442
0
    return "An invalid 'part' argument was passed as argument";
443
444
0
  case CURLUE_MALFORMED_INPUT:
445
0
    return "Malformed input to a URL function";
446
447
0
  case CURLUE_BAD_PORT_NUMBER:
448
0
    return "Port number was not a decimal number between 0 and 65535";
449
450
0
  case CURLUE_UNSUPPORTED_SCHEME:
451
0
    return "Unsupported URL scheme";
452
453
0
  case CURLUE_URLDECODE:
454
0
    return "URL decode error, most likely because of rubbish in the input";
455
456
0
  case CURLUE_OUT_OF_MEMORY:
457
0
    return "A memory function failed";
458
459
0
  case CURLUE_USER_NOT_ALLOWED:
460
0
    return "Credentials was passed in the URL when prohibited";
461
462
0
  case CURLUE_UNKNOWN_PART:
463
0
    return "An unknown part ID was passed to a URL API function";
464
465
0
  case CURLUE_NO_SCHEME:
466
0
    return "No scheme part in the URL";
467
468
0
  case CURLUE_NO_USER:
469
0
    return "No user part in the URL";
470
471
0
  case CURLUE_NO_PASSWORD:
472
0
    return "No password part in the URL";
473
474
0
  case CURLUE_NO_OPTIONS:
475
0
    return "No options part in the URL";
476
477
0
  case CURLUE_NO_HOST:
478
0
    return "No host part in the URL";
479
480
0
  case CURLUE_NO_PORT:
481
0
    return "No port part in the URL";
482
483
0
  case CURLUE_NO_QUERY:
484
0
    return "No query part in the URL";
485
486
0
  case CURLUE_NO_FRAGMENT:
487
0
    return "No fragment part in the URL";
488
489
0
  case CURLUE_NO_ZONEID:
490
0
    return "No zoneid part in the URL";
491
492
0
  case CURLUE_BAD_LOGIN:
493
0
    return "Bad login part";
494
495
0
  case CURLUE_BAD_IPV6:
496
0
    return "Bad IPv6 address";
497
498
0
  case CURLUE_BAD_HOSTNAME:
499
0
    return "Bad hostname";
500
501
0
  case CURLUE_BAD_FILE_URL:
502
0
    return "Bad file:// URL";
503
504
0
  case CURLUE_BAD_SLASHES:
505
0
    return "Unsupported number of slashes following scheme";
506
507
0
  case CURLUE_BAD_SCHEME:
508
0
    return "Bad scheme";
509
510
0
  case CURLUE_BAD_PATH:
511
0
    return "Bad path";
512
513
0
  case CURLUE_BAD_FRAGMENT:
514
0
    return "Bad fragment";
515
516
0
  case CURLUE_BAD_QUERY:
517
0
    return "Bad query";
518
519
0
  case CURLUE_BAD_PASSWORD:
520
0
    return "Bad password";
521
522
0
  case CURLUE_BAD_USER:
523
0
    return "Bad user";
524
525
0
  case CURLUE_LACKS_IDN:
526
0
    return "libcurl lacks IDN support";
527
528
0
  case CURLUE_TOO_LARGE:
529
0
    return "A value or data field is larger than allowed";
530
531
0
  case CURLUE_LAST:
532
0
    break;
533
0
  }
534
535
0
  return "CURLUcode unknown";
536
#else
537
  if(error == CURLUE_OK)
538
    return "No error";
539
  else
540
    return "Error";
541
#endif
542
0
}
543
544
#ifdef USE_WINDOWS_SSPI
545
/*
546
 * Curl_sspi_strerror:
547
 * Variant of curlx_strerror if the error code is definitely Windows SSPI.
548
 */
549
const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
550
{
551
#ifdef _WIN32
552
  DWORD old_win_err = GetLastError();
553
#endif
554
  int old_errno = errno;
555
  const char *txt;
556
557
  if(!buflen)
558
    return NULL;
559
560
  *buf = '\0';
561
562
#ifndef CURL_DISABLE_VERBOSE_STRINGS
563
564
  switch(err) {
565
    case SEC_E_OK:
566
      txt = "No error";
567
      break;
568
#define SEC2TXT(sec) case sec: txt = #sec; break
569
    SEC2TXT(CRYPT_E_REVOKED);
570
    SEC2TXT(CRYPT_E_NO_REVOCATION_DLL);
571
    SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK);
572
    SEC2TXT(CRYPT_E_REVOCATION_OFFLINE);
573
    SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE);
574
    SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
575
    SEC2TXT(SEC_E_BAD_BINDINGS);
576
    SEC2TXT(SEC_E_BAD_PKGID);
577
    SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
578
    SEC2TXT(SEC_E_CANNOT_INSTALL);
579
    SEC2TXT(SEC_E_CANNOT_PACK);
580
    SEC2TXT(SEC_E_CERT_EXPIRED);
581
    SEC2TXT(SEC_E_CERT_UNKNOWN);
582
    SEC2TXT(SEC_E_CERT_WRONG_USAGE);
583
    SEC2TXT(SEC_E_CONTEXT_EXPIRED);
584
    SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
585
    SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
586
    SEC2TXT(SEC_E_DECRYPT_FAILURE);
587
    SEC2TXT(SEC_E_DELEGATION_POLICY);
588
    SEC2TXT(SEC_E_DELEGATION_REQUIRED);
589
    SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
590
    SEC2TXT(SEC_E_ENCRYPT_FAILURE);
591
    SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
592
    SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
593
    SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
594
    SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
595
    SEC2TXT(SEC_E_INTERNAL_ERROR);
596
    SEC2TXT(SEC_E_INVALID_HANDLE);
597
    SEC2TXT(SEC_E_INVALID_PARAMETER);
598
    SEC2TXT(SEC_E_INVALID_TOKEN);
599
    SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
600
    SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
601
    SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
602
    SEC2TXT(SEC_E_KDC_CERT_REVOKED);
603
    SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
604
    SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
605
    SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
606
    SEC2TXT(SEC_E_LOGON_DENIED);
607
    SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
608
    SEC2TXT(SEC_E_MESSAGE_ALTERED);
609
    SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
610
    SEC2TXT(SEC_E_MUST_BE_KDC);
611
    SEC2TXT(SEC_E_NOT_OWNER);
612
    SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
613
    SEC2TXT(SEC_E_NO_CREDENTIALS);
614
    SEC2TXT(SEC_E_NO_IMPERSONATION);
615
    SEC2TXT(SEC_E_NO_IP_ADDRESSES);
616
    SEC2TXT(SEC_E_NO_KERB_KEY);
617
    SEC2TXT(SEC_E_NO_PA_DATA);
618
    SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
619
    SEC2TXT(SEC_E_NO_TGT_REPLY);
620
    SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
621
    SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
622
    SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
623
    SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
624
    SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
625
    SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
626
    SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
627
    SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
628
    SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
629
    SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
630
    SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
631
    SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
632
    SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
633
    SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
634
    SEC2TXT(SEC_E_TARGET_UNKNOWN);
635
    SEC2TXT(SEC_E_TIME_SKEW);
636
    SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
637
    SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
638
    SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
639
    SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
640
    SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
641
    SEC2TXT(SEC_E_UNTRUSTED_ROOT);
642
    SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
643
    SEC2TXT(SEC_E_WRONG_PRINCIPAL);
644
    SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
645
    SEC2TXT(SEC_I_COMPLETE_NEEDED);
646
    SEC2TXT(SEC_I_CONTEXT_EXPIRED);
647
    SEC2TXT(SEC_I_CONTINUE_NEEDED);
648
    SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
649
    SEC2TXT(SEC_I_LOCAL_LOGON);
650
    SEC2TXT(SEC_I_NO_LSA_CONTEXT);
651
    SEC2TXT(SEC_I_RENEGOTIATE);
652
    SEC2TXT(SEC_I_SIGNATURE_NEEDED);
653
    default:
654
      txt = "Unknown error";
655
  }
656
657
  if(err == SEC_E_ILLEGAL_MESSAGE) {
658
    curl_msnprintf(buf, buflen,
659
                   "SEC_E_ILLEGAL_MESSAGE (0x%08lx) - This error usually "
660
                   "occurs when a fatal SSL/TLS alert is received (e.g. "
661
                   "handshake failed). More detail may be available in "
662
                   "the Windows System event log.", err);
663
  }
664
  else {
665
    char msgbuf[256];
666
    if(curlx_get_winapi_error((DWORD)err, msgbuf, sizeof(msgbuf)))
667
      curl_msnprintf(buf, buflen, "%s (0x%08lx) - %s", txt, err, msgbuf);
668
    else
669
      curl_msnprintf(buf, buflen, "%s (0x%08lx)", txt, err);
670
  }
671
672
#else
673
  if(err == SEC_E_OK)
674
    txt = "No error";
675
  else
676
    txt = "Error";
677
  if(buflen > strlen(txt))
678
    strcpy(buf, txt);
679
#endif
680
681
  if(errno != old_errno)
682
    CURL_SETERRNO(old_errno);
683
684
#ifdef _WIN32
685
  if(old_win_err != GetLastError())
686
    SetLastError(old_win_err);
687
#endif
688
689
  return buf;
690
}
691
#endif /* USE_WINDOWS_SSPI */