From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.bugs Subject: bug#31946: 27.0.50; The NSM should warn about more TLS problems Date: Mon, 26 Aug 2019 23:56:06 +0100 Message-ID: <86d0grfse1.fsf@gmail.com> References: <87h8647de5.fsf@gnus.org> <86tva4dq8h.fsf@gmail.com> <83k1azgbbi.fsf@gnu.org> <86zhjvrfbp.fsf@gmail.com> <83blwbg5i2.fsf@gnu.org> <86tva3rdpv.fsf@gmail.com> <834l23g1mg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="44577"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt) To: 31946@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 27 00:57:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i2NvG-000BRm-90 for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Aug 2019 00:57:14 +0200 Original-Received: from localhost ([::1]:58216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2NvF-0001yP-7O for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Aug 2019 18:57:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53444) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2Nv6-0001xc-8z for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:57:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2Nv4-0003cA-2N for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:57:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2Nv3-0003c1-Vg for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i2Nv3-0007af-T9 for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:57:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Andy Moreton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Aug 2019 22:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31946 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: security fixed X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156686019029110 (code B ref -1); Mon, 26 Aug 2019 22:57:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Aug 2019 22:56:30 +0000 Original-Received: from localhost ([127.0.0.1]:47298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i2NuY-0007ZS-6V for submit@debbugs.gnu.org; Mon, 26 Aug 2019 18:56:30 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:51339) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i2NuW-0007ZI-C8 for submit@debbugs.gnu.org; Mon, 26 Aug 2019 18:56:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2NuV-0001rH-2B for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:56:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2NuT-0003T7-TJ for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:56:26 -0400 Original-Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:38596 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2NuT-0003Sd-Mw for bug-gnu-emacs@gnu.org; Mon, 26 Aug 2019 18:56:25 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1i2NuL-000AO2-EZ for bug-gnu-emacs@gnu.org; Tue, 27 Aug 2019 00:56:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:B2/FNJCs7xSxvtug2i8+Go6s3wg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:165923 Archived-At: On Mon 26 Aug 2019, Eli Zaretskii wrote: >> From: Andy Moreton >> Date: Mon, 26 Aug 2019 19:19:56 +0100 >> >> On Mon 26 Aug 2019, Eli Zaretskii wrote: >> >> >> Agreed, but master built from commit 1071a4f still crashes in the same >> >> way: >> > >> > Can you show a recipe? >> >> 1) Delete ~/.emacs.d/network-security.data (to ensure NSM will query the user). >> 2) Run "emacs -Q" >> 3) "M-x list-packages", and at the NSM prompt, answer 'a' or 's' or 'd'. > > Looks like something is wrong with how I'm using gnutls_free when it > comes from the DLL. I need to look into that. Found it I think. gnutls_free is a pointer of type gnutls_free_function, so the value returned from GetProcAddress is a data pointer, not a function address. Something like the following patch appears to work i.e. no longer crashes with the recipe above. If this is the right fix then we will need to add e.g. DEF_DLL_DATA and LOAD_DLL_DATA macros for runtime import of data (and an equivalent to get_proc_addr to use the right types for runtime data imports). The patch also has "#undef gnutls_free" because gnutls.h also defines gnutls_free as a macro, if GNUTLS_INTERNAL_BUILD is defined. For some reason the MSYS2 maintainers add a patch to their build to define GNUTLS_INTERNAL_BUILD unconditionally: see 0001-add-missing-define.patch at . diff --git a/src/gnutls.c b/src/gnutls.c index 67d1fb9552..c4bce62869 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -140,6 +140,7 @@ DEF_DLL_FN (void, gnutls_dh_set_prime_bits, DEF_DLL_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); DEF_DLL_FN (int, gnutls_error_is_fatal, (int)); DEF_DLL_FN (int, gnutls_global_init, (void)); +#undef gnutls_free /* Also defined as a macro in gnutls.h */ DEF_DLL_FN (void, gnutls_free, (void *)); DEF_DLL_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); # ifdef HAVE_GNUTLS3 @@ -1616,7 +1617,7 @@ DEFUN ("gnutls-format-certificate", Fgnutls_format_certificate, memset (out_buf, 0, (out.size + 1) * sizeof (char)); memcpy (out_buf, out.data, out.size); - gnutls_free (out.data); + (*((gnutls_free_function *)gnutls_free)) (out.data); gnutls_x509_crt_deinit (crt); Lisp_Object result = build_string (out_buf);