[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 198/205: openssl: make SSL_ERROR_to_str more future
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 198/205: openssl: make SSL_ERROR_to_str more future-proof |
Date: |
Thu, 20 Apr 2017 16:22:18 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.54.0
in repository gnurl.
commit 47b2f89d7c7e1440a344e6e82a9390e0f912d2f8
Author: David Benjamin <address@hidden>
AuthorDate: Mon Apr 17 09:42:03 2017 -0400
openssl: make SSL_ERROR_to_str more future-proof
Rather than making assumptions about the values, use a switch-case.
Closes #1424
---
lib/vtls/openssl.c | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 5c4e34e91..35489f845 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -164,22 +164,40 @@ static unsigned long OpenSSL_version_num(void)
static const char *SSL_ERROR_to_str(int err)
{
- static const char * const str[] = {
- "SSL_ERROR_NONE", /* 0 */
- "SSL_ERROR_SSL", /* 1 */
- "SSL_ERROR_WANT_READ", /* 2 */
- "SSL_ERROR_WANT_WRITE", /* 3 */
- "SSL_ERROR_WANT_X509_LOOKUP", /* 4 */
- "SSL_ERROR_SYSCALL", /* 5 */
- "SSL_ERROR_ZERO_RETURN", /* 6 */
- "SSL_ERROR_WANT_CONNECT", /* 7 */
- "SSL_ERROR_WANT_ACCEPT", /* 8 */
- "SSL_ERROR_WANT_ASYNC", /* 9 */
- "SSL_ERROR_WANT_ASYNC_JOB", /* 10 */
- "SSL_ERROR_WANT_EARLY", /* 11 */
- };
- return ((err >= 0 && err < (int)(sizeof str / sizeof str[0])) ?
- str[err] : "SSL_ERROR unknown");
+ switch(err) {
+ case SSL_ERROR_NONE:
+ return "SSL_ERROR_NONE";
+ case SSL_ERROR_SSL:
+ return "SSL_ERROR_SSL";
+ case SSL_ERROR_WANT_READ:
+ return "SSL_ERROR_WANT_READ";
+ case SSL_ERROR_WANT_WRITE:
+ return "SSL_ERROR_WANT_WRITE";
+ case SSL_ERROR_WANT_X509_LOOKUP:
+ return "SSL_ERROR_WANT_X509_LOOKUP";
+ case SSL_ERROR_SYSCALL:
+ return "SSL_ERROR_SYSCALL";
+ case SSL_ERROR_ZERO_RETURN:
+ return "SSL_ERROR_ZERO_RETURN";
+ case SSL_ERROR_WANT_CONNECT:
+ return "SSL_ERROR_WANT_CONNECT";
+ case SSL_ERROR_WANT_ACCEPT:
+ return "SSL_ERROR_WANT_ACCEPT";
+#if defined(SSL_ERROR_WANT_ASYNC)
+ case SSL_ERROR_WANT_ASYNC:
+ return "SSL_ERROR_WANT_ASYNC";
+#endif
+#if defined(SSL_ERROR_WANT_ASYNC_JOB)
+ case SSL_ERROR_WANT_ASYNC_JOB:
+ return "SSL_ERROR_WANT_ASYNC_JOB";
+#endif
+#if defined(SSL_ERROR_WANT_EARLY)
+ case SSL_ERROR_WANT_EARLY:
+ return "SSL_ERROR_WANT_EARLY";
+#endif
+ default:
+ return "SSL_ERROR unknown";
+ }
}
static int passwd_callback(char *buf, int num, int encrypting,
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 19/205: no-keepalive.d: fix typo, (continued)
- [GNUnet-SVN] [gnurl] 19/205: no-keepalive.d: fix typo, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 123/205: KNOWN_BUGS: typo, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 135/205: http2: silence unused parameter warnings, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 177/205: .github/stale.yml: enable the stale bot, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 96/205: docs: split file lists into Makefile.inc, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 171/205: schannel: fix compiler warnings, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 183/205: poll: prefer <poll.h> over <sys/poll.h>, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 43/205: Makefile.am: Added scripts/updatemanpages.pl to EXTRA_DIST, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 194/205: .gitattributes: force shell scripts to LF, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 68/205: mbedtls: fix typo in variable name, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 198/205: openssl: make SSL_ERROR_to_str more future-proof,
gnunet <=
- [GNUnet-SVN] [gnurl] 178/205: libcurl-thread.3: also mention threaded-resolver, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 145/205: docs: added examples for CURLINFO_FILETIME.3 and CURLOPT_FILETIME.3, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 156/205: tool: fix Windows Unicode build, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 59/205: openssl: add two /* FALLTHROUGH */ to satisfy coverity, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 99/205: mbedtls: add support for CURLOPT_SSL_CTX_FUNCTION, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 203/205: RELEASE-NOTES: curl 7.54.0, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 112/205: spelling fixes, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 93/205: RELEASE-NOTES: synced with 6e0f26c8a8c28df, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 111/205: curl: check for end of input in writeout backslash handling, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 163/205: test1541: ignore the curl_off_t variable type name comparison, gnunet, 2017/04/20