all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 25061@debbugs.gnu.org
Subject: bug#25061: consider adding %COMPAT to default gnutls priority string
Date: Wed, 20 Dec 2017 16:38:20 +0000	[thread overview]
Message-ID: <vz1mv2dz75v.fsf@gmail.com> (raw)
In-Reply-To: <87zikiwpl6.fsf@igalia.com>

On Wed 20 Dec 2017, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Wed, 20 Dec 2017 12:54:45 +0000
>> 
>> diff --git a/src/gnutls.c b/src/gnutls.c
>> index 8db201ae83..f2b078d964 100644
>> --- a/src/gnutls.c
>> +++ b/src/gnutls.c
>> @@ -238,6 +238,7 @@ DEF_DLL_FN (int, gnutls_hash, (gnutls_hash_hd_t, const void *, size_t));
>>  DEF_DLL_FN (void, gnutls_hash_deinit, (gnutls_hash_hd_t, void *));
>>  DEF_DLL_FN (void, gnutls_hash_output, (gnutls_hash_hd_t, void *));
>>  #  endif        /* HAVE_GNUTLS3 */
>> +DEF_DLL_FN (const char *, gnutls_ext_get_name, (unsigned int));
>> 
>> 
>>  static bool
>> @@ -357,6 +358,7 @@ init_gnutls_functions (void)
>>    LOAD_DLL_FN (library, gnutls_hash_deinit);
>>    LOAD_DLL_FN (library, gnutls_hash_output);
>>  #  endif        /* HAVE_GNUTLS3 */
>> +  LOAD_DLL_FN (library, gnutls_ext_get_name);
>> 
>>    max_log_level = global_gnutls_log_level;
>> 
>> @@ -470,6 +472,8 @@ init_gnutls_functions (void)
>>  #  define gnutls_hash_deinit fn_gnutls_hash_deinit
>>  #  define gnutls_hash_output fn_gnutls_hash_output
>>  #  endif        /* HAVE_GNUTLS3 */
>> +#  define gnutls_ext_get_name fn_gnutls_ext_get_name
>
> Thanks, but this means Emacs will now refuse to load GnuTLS on systems
> that have version 3.4 or older of the library, right?  If so, I think
> the loading and the use of the function should be conditioned by an
> appropriate preprocessor directive to compile that code only for
> 3.5.X.

Agreed. This version also fixes a bug in the previous version, where
the capabilities stored in Vlibrary_cache were not updated properly.


diff --git a/src/gnutls.c b/src/gnutls.c
index 8db201ae83..48ea25397a 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -46,6 +46,10 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 # define HAVE_GNUTLS_MAC_GET_NONCE_SIZE
 #endif
 
+#if GNUTLS_VERSION_NUMBER >= 0x030501
+# define HAVE_GNUTLS_EXT_GET_NAME
+#endif
+
 #ifdef HAVE_GNUTLS
 
 # ifdef WINDOWSNT
@@ -237,6 +241,9 @@ DEF_DLL_FN (int, gnutls_hash_get_len, (gnutls_digest_algorithm_t));
 DEF_DLL_FN (int, gnutls_hash, (gnutls_hash_hd_t, const void *, size_t));
 DEF_DLL_FN (void, gnutls_hash_deinit, (gnutls_hash_hd_t, void *));
 DEF_DLL_FN (void, gnutls_hash_output, (gnutls_hash_hd_t, void *));
+#   ifdef HAVE_GNUTLS_EXT_GET_NAME
+DEF_DLL_FN (const char *, gnutls_ext_get_name, (unsigned int));
+#   endif
 #  endif	 /* HAVE_GNUTLS3 */
 
 
@@ -356,6 +363,9 @@ init_gnutls_functions (void)
   LOAD_DLL_FN (library, gnutls_hash);
   LOAD_DLL_FN (library, gnutls_hash_deinit);
   LOAD_DLL_FN (library, gnutls_hash_output);
+#   ifdef HAVE_GNUTLS_EXT_GET_NAME
+  LOAD_DLL_FN (library, gnutls_ext_get_name);
+#   endif
 #  endif	 /* HAVE_GNUTLS3 */
 
   max_log_level = global_gnutls_log_level;
@@ -469,8 +479,12 @@ init_gnutls_functions (void)
 #  define gnutls_hash fn_gnutls_hash
 #  define gnutls_hash_deinit fn_gnutls_hash_deinit
 #  define gnutls_hash_output fn_gnutls_hash_output
+#   ifdef HAVE_GNUTLS_EXT_GET_NAME
+#    define gnutls_ext_get_name fn_gnutls_ext_get_name
+#   endif
 #  endif	 /* HAVE_GNUTLS3 */
 
+
 /* This wrapper is called from fns.c, which doesn't know about the
    LOAD_DLL_FN stuff above.  */
 int
@@ -2425,6 +2439,18 @@ Any GnuTLS extension with ID up to 100
 
 #ifdef HAVE_GNUTLS
 
+# ifdef WINDOWSNT
+  Lisp_Object found = Fassq (Qgnutls, Vlibrary_cache);
+  if (CONSP (found))
+    return XCDR (found);
+
+  /* Load the GnuTLS DLL and find exported functions.  The external
+     library cache is updated after the capabilities have been
+     determined.  */
+  if (!init_gnutls_functions ())
+    return Qnil;
+# endif /* WINDOWSNT */
+
   capabilities = Fcons (intern("gnutls"), capabilities);
 
 # ifdef HAVE_GNUTLS3
@@ -2437,8 +2463,8 @@ Any GnuTLS extension with ID up to 100
 #  endif
 
   capabilities = Fcons (intern("macs"), capabilities);
-# endif	  /* HAVE_GNUTLS3 */
 
+#  ifdef HAVE_GNUTLS_EXT_GET_NAME
   for (unsigned int ext=0; ext < 100; ext++)
     {
       const char* name = gnutls_ext_get_name(ext);
@@ -2447,18 +2473,11 @@ Any GnuTLS extension with ID up to 100
           capabilities = Fcons (intern(name), capabilities);
         }
     }
+#  endif
+# endif	  /* HAVE_GNUTLS3 */
 
 # ifdef WINDOWSNT
-  Lisp_Object found = Fassq (Qgnutls, Vlibrary_cache);
-  if (CONSP (found))
-    return XCDR (found);
-  else
-    {
-      Lisp_Object status;
-      status = init_gnutls_functions () ? capabilities : Qnil;
-      Vlibrary_cache = Fcons (Fcons (Qgnutls, status), Vlibrary_cache);
-      return status;
-    }
+  Vlibrary_cache = Fcons (Fcons (Qgnutls, capabilities), Vlibrary_cache);
 # endif /* WINDOWSNT */
 #endif	/* HAVE_GNUTLS */
 






  reply	other threads:[~2017-12-20 16:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 10:24 bug#25061: consider adding %COMPAT to default gnutls priority string Andy Wingo
2016-12-01 18:32 ` Ted Zlatanov
2016-12-01 20:25   ` Ludovic Courtès
2016-12-01 21:44     ` Ted Zlatanov
2017-01-24 22:48       ` Lars Ingebrigtsen
2017-01-30  8:01         ` Ludovic Courtès
2017-02-10 15:51           ` Andy Wingo
2017-02-13 16:04             ` Ted Zlatanov
2017-09-02 13:49               ` Eli Zaretskii
2017-09-06 19:32                 ` Ted Zlatanov
2017-09-07  7:18                   ` Michael Albinus
2017-09-14 21:11                     ` Ted Zlatanov
2017-09-15  6:05                       ` Eli Zaretskii
2017-12-02 17:36                         ` Eli Zaretskii
2017-12-09 23:50                           ` Ted Zlatanov
2017-12-10  7:04                             ` Eli Zaretskii
2017-12-10 13:29                               ` Ted Zlatanov
2017-12-10 14:12                                 ` Eli Zaretskii
2017-12-11 15:03                                   ` Ted Zlatanov
2017-12-11 15:40                                     ` Eli Zaretskii
2017-12-15  4:18                                       ` Ted Zlatanov
2017-12-16 23:25                                         ` Philipp Stephani
2017-12-16 23:34                                           ` Ted Zlatanov
2017-12-17  3:39                                             ` Eli Zaretskii
2017-12-17 15:17                                               ` Eli Zaretskii
2017-12-19 17:46                                                 ` Ted Zlatanov
2017-12-17 17:52                                               ` Philipp Stephani
2017-12-10  9:31                             ` Michael Albinus
2017-12-18 17:16 ` Kaushal Modi
2017-12-18 19:52   ` Philipp Stephani
2017-12-19 17:47   ` Ted Zlatanov
2017-12-19 22:00     ` Kaushal Modi
2017-12-20  1:08       ` Ted Zlatanov
2017-12-20 11:41         ` Robert Pluim
2017-12-20 16:09           ` Eli Zaretskii
2017-12-21 13:20             ` Kaushal Modi
2017-12-21 13:26               ` Ted Zlatanov
2017-12-20 11:48         ` Kaushal Modi
2017-12-20 12:54         ` Andy Moreton
2017-12-20 13:16           ` Andy Moreton
2017-12-20 16:19           ` Eli Zaretskii
2017-12-20 16:38             ` Andy Moreton [this message]
2017-12-21  1:15             ` Ted Zlatanov
2017-12-21  1:39               ` Ted Zlatanov
2017-12-21  8:30                 ` Robert Pluim
2017-12-21 13:12                   ` Ted Zlatanov
2017-12-21 16:20                 ` Eli Zaretskii
2017-12-21 10:54               ` Andy Moreton
2017-12-21 16:26                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vz1mv2dz75v.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=25061@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.