]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
GNUTLS_E_NO_PRIORITIES_WERE_SET is also returned by gnutls_priority_set_*
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 18 Jan 2012 18:57:45 +0000 (19:57 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 18 Jan 2012 18:57:45 +0000 (19:57 +0100)
This allows to warn when an incomplete set of priorities is specified.
Reported by Yaroslav Stavnichiy.

NEWS
lib/gnutls_errors.c
lib/gnutls_priority.c
src/cli.c

diff --git a/NEWS b/NEWS
index 1373bcf06bee8acf6e0ae63f09f1c53817a10b70..76fa241f7a794800638d44a97d8da69548e1c7fe 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ See the end for copying conditions.
 ** certtool: --outder option now works for private
 and public keys as well.
 
+** libgnutls: Added error code GNUTLS_E_NO_PRIORITIES_WERE_SET
+to warn when no or insufficient priorities were set.
+
 ** libgnutls: Corrected an alignment issue in ECDH
 key generation which prevented some keys from being
 correctly aligned in rare circumstances.
index e1def739cb82c9931d3d2350ca9e4d2924c8b302..d228cc35f60353f2524530e06c3103eddc17c223 100644 (file)
@@ -51,7 +51,7 @@ static const gnutls_error_entry error_algorithms[] = {
   ERROR_ENTRY (N_("Success."), GNUTLS_E_SUCCESS, 0),
   ERROR_ENTRY (N_("Could not negotiate a supported cipher suite."),
                GNUTLS_E_UNKNOWN_CIPHER_SUITE, 1),
-  ERROR_ENTRY (N_("No priorities were setup."),
+  ERROR_ENTRY (N_("No or insufficient priorities were set."),
                GNUTLS_E_NO_PRIORITIES_WERE_SET, 1),
   ERROR_ENTRY (N_("The cipher type is unsupported."),
                GNUTLS_E_UNKNOWN_CIPHER_TYPE, 1),
index 1c2964eeb714ed4a221022311ad15109319773b0..29fc363c7b82d4d74821896b6cb5b8b352893447 100644 (file)
@@ -576,6 +576,13 @@ gnutls_priority_set (gnutls_session_t session, gnutls_priority_t priority)
                                  session->internals.priorities.protocol.
                                  priority[0]);
 
+  if (session->internals.priorities.protocol.algorithms == 0 ||
+      session->internals.priorities.cipher.algorithms == 0 ||
+      session->internals.priorities.mac.algorithms == 0 ||
+      session->internals.priorities.kx.algorithms == 0 ||
+      session->internals.priorities.compression.algorithms == 0)
+    return gnutls_assert_val(GNUTLS_E_NO_PRIORITIES_WERE_SET);
+
   return 0;
 }
 
index bde68eb7ad06a3d8a636ef1974a72d47122360d6..722f85f660034857dc9b8eb37e5e429ed7684f5b 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -545,6 +545,7 @@ static gnutls_session_t
 init_tls_session (const char *hostname)
 {
   const char *err;
+  int ret;
 
   gnutls_session_t session;
 
@@ -558,9 +559,11 @@ init_tls_session (const char *hostname)
     gnutls_init (&session, GNUTLS_CLIENT);
 
 
-  if (gnutls_priority_set_direct (session, info.priorities, &err) < 0)
+  if ((ret = gnutls_priority_set_direct (session, info.priorities, &err)) < 0)
     {
-      fprintf (stderr, "Syntax error at: %s\n", err);
+      if (ret == GNUTLS_E_INVALID_REQUEST) fprintf (stderr, "Syntax error at: %s\n", err);
+      else 
+        fprintf(stderr, "Error in priorities: %s\n", gnutls_strerror(ret));
       exit (1);
     }