[vlc-commits] gnutls: kill relocations

Rémi Denis-Courmont git at videolan.org
Sun Sep 30 14:28:34 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 30 15:12:43 2012 +0300| [75ffd9eaf71597a3c457bcb543d377121cda1e58] | committer: Rémi Denis-Courmont

gnutls: kill relocations

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=75ffd9eaf71597a3c457bcb543d377121cda1e58
---

 modules/misc/gnutls.c |   26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 638fc3e..3587307 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -240,13 +240,11 @@ static int gnutls_ContinueHandshake (vlc_tls_t *session)
 }
 
 
-typedef struct
+static struct
 {
     int flag;
-    const char *msg;
-} error_msg_t;
-
-static const error_msg_t cert_errors[] =
+    const char msg[44];
+} cert_errs[] =
 {
     { GNUTLS_CERT_INVALID,
         "Certificate could not be verified" },
@@ -262,7 +260,6 @@ static const error_msg_t cert_errors[] =
         "Certificate is not yet activated" },
     { GNUTLS_CERT_EXPIRED,
         "Certificate has expired" },
-    { 0, NULL }
 };
 
 
@@ -280,26 +277,23 @@ static int gnutls_HandshakeAndValidate (vlc_tls_t *session)
     val = gnutls_certificate_verify_peers2 (sys->session, &status);
     if (val)
     {
-        msg_Err (session, "Certificate verification failed: %s",
+        msg_Err (session, "Certificate verification error: %s",
                  gnutls_strerror (val));
         return -1;
     }
 
     if (status)
     {
-        msg_Err (session, "TLS session: access denied (status 0x%X)", status);
-        for (const error_msg_t *e = cert_errors; e->flag; e++)
-        {
-            if (status & e->flag)
+        msg_Err (session, "Certificate verification failure:");
+        for (size_t i = 0; i < sizeof (cert_errs) / sizeof (cert_errs[0]); i++)
+            if (status & cert_errs[i].flag)
             {
-                msg_Err (session, "%s", e->msg);
-                status &= ~e->flag;
+                msg_Err (session, " * %s", cert_errs[i].msg);
+                status &= ~cert_errs[i].flag;
             }
-        }
 
         if (status)
-            msg_Err (session,
-                     "unknown certificate error (you found a bug in VLC)");
+            msg_Err (session, " * Unknown verification error 0x%04X", status);
         return -1;
     }
 



More information about the vlc-commits mailing list