]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ngtcp2: fix thread-safety bug in error-handling
authorDavid Benjamin <davidben@google.com>
Wed, 27 Nov 2019 21:53:51 +0000 (16:53 -0500)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 27 Nov 2019 23:48:19 +0000 (00:48 +0100)
ERR_error_string(NULL) should never be called. It places the error in a
global buffer, which is not thread-safe. Use ERR_error_string_n with a
local buffer instead.

Closes #4645

lib/vquic/ngtcp2.c

index 071d45c027756543c0a20accfb61d3303182f2c4..7d8b98e90ca7eef38d70e4b8893da9f1732b5318 100644 (file)
@@ -256,8 +256,9 @@ static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data)
   SSL_CTX_set_default_verify_paths(ssl_ctx);
 
   if(SSL_CTX_set_ciphersuites(ssl_ctx, QUIC_CIPHERS) != 1) {
-    failf(data, "SSL_CTX_set_ciphersuites: %s",
-          ERR_error_string(ERR_get_error(), NULL));
+    char error_buffer[256];
+    ERR_error_string_n(ERR_get_error(), error_buffer, sizeof(error_buffer));
+    failf(data, "SSL_CTX_set_ciphersuites: %s", error_buffer);
     return NULL;
   }