[glib-networking: 100/129] fix data race condition in END_OPENSSL_IO



commit 833e257c500484bc0356ccc98d400b6761963fd2
Author: Silvio Lazzeretti <silviola amazon com>
Date:   Thu Mar 1 15:33:59 2018 +0100

    fix data race condition in END_OPENSSL_IO
    
    The ERR_error_string function is using a static
    buffer to return the error string and this can
    cause a data race in multithreaded environments.

 tls/openssl/gtlsconnection-openssl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index c3caec6..0962364 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -201,10 +201,12 @@ end_openssl_io (GTlsConnectionOpenssl  *openssl,
 #define BEGIN_OPENSSL_IO(openssl, direction, blocking, cancellable)        \
   g_tls_connection_base_push_io (G_TLS_CONNECTION_BASE (openssl),        \
                                  direction, blocking, cancellable);        \
-  do {
+  do {                                                                      \
+    char error_str[256];                                                  \
 
 #define END_OPENSSL_IO(openssl, direction, ret, status, errmsg, err)        \
-    status = end_openssl_io (openssl, direction, ret, err, errmsg, ERR_error_string (SSL_get_error (ssl, 
ret), NULL)); \
+    ERR_error_string_n (SSL_get_error (ssl, ret), error_str, sizeof(error_str)); \
+    status = end_openssl_io (openssl, direction, ret, err, errmsg, error_str, NULL); \
   } while (status == G_TLS_CONNECTION_BASE_TRY_AGAIN);
 
 static GTlsConnectionBaseStatus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]