[glib-networking] openssl: Really fix max protocol error message format



commit 5cf118ca0322ca6378e2024e278459e2acca89da
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Fri Jun 4 08:30:41 2021 -0500

    openssl: Really fix max protocol error message format
    
    Third time is the charm! We keep the result of g_ascii_strtoll() and
    simply check to ensure it's within the range of an int before passing it
    to openssl or printing it.

 tls/openssl/gtlsclientconnection-openssl.c | 6 +++---
 tls/openssl/gtlsserverconnection-openssl.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/tls/openssl/gtlsclientconnection-openssl.c b/tls/openssl/gtlsclientconnection-openssl.c
index aad011f..0e83b03 100644
--- a/tls/openssl/gtlsclientconnection-openssl.c
+++ b/tls/openssl/gtlsclientconnection-openssl.c
@@ -328,13 +328,13 @@ set_max_protocol (GTlsClientConnectionOpenssl  *client,
     {
       gint64 version = g_ascii_strtoll (proto, NULL, 0);
 
-      if (version > 0 && version < G_MAXINT64)
+      if (version > 0 && version < G_MAXINT)
         {
           if (!SSL_CTX_set_max_proto_version (client->ssl_ctx, (int)version))
             {
               g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
-                           _("Could not set MAX protocol to %ld: %s"),
-                           version, ERR_error_string (ERR_get_error (), NULL));
+                           _("Could not set MAX protocol to %d: %s"),
+                           (int)version, ERR_error_string (ERR_get_error (), NULL));
               return FALSE;
             }
         }
diff --git a/tls/openssl/gtlsserverconnection-openssl.c b/tls/openssl/gtlsserverconnection-openssl.c
index a809f60..b648be1 100644
--- a/tls/openssl/gtlsserverconnection-openssl.c
+++ b/tls/openssl/gtlsserverconnection-openssl.c
@@ -364,13 +364,13 @@ set_max_protocol (GTlsServerConnectionOpenssl  *server,
     {
       gint64 version = g_ascii_strtoll (proto, NULL, 0);
 
-      if (version > 0 && version < G_MAXINT64)
+      if (version > 0 && version < G_MAXINT)
         {
           if (!SSL_CTX_set_max_proto_version (server->ssl_ctx, (int)version))
             {
               g_set_error (error, G_TLS_ERROR, G_TLS_ERROR_MISC,
-                           _("Could not set MAX protocol to %ld: %s"),
-                           version, ERR_error_string (ERR_get_error (), NULL));
+                           _("Could not set MAX protocol to %d: %s"),
+                           (int)version, ERR_error_string (ERR_get_error (), NULL));
               return FALSE;
             }
         }


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