diff options
| author | Eli Zaretskii | 2019-08-26 19:06:13 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-08-26 19:06:13 +0300 |
| commit | 1071a4fac6f2e70572a1259e073124cbb723e90d (patch) | |
| tree | f5957792fca483ae0826afae2eeacad792b3ec96 /src | |
| parent | f87ace2aed492d5d605da59b59af6fad5f0e33e4 (diff) | |
| download | emacs-1071a4fac6f2e70572a1259e073124cbb723e90d.tar.gz emacs-1071a4fac6f2e70572a1259e073124cbb723e90d.zip | |
Fix crashes in networking with GnuTLS on MS-Windows
* src/gnutls.c (init_gnutls_functions) [WINDOWSNT]: Define and
load gnutls_free.
(Fgnutls_format_certificate): Use gnutls_free instead of
xfree. This prevents crashes on MS-Windows, since the memory
being released was allocated inside GnuTLS. (Bug#31946)
Diffstat (limited to 'src')
| -rw-r--r-- | src/gnutls.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gnutls.c b/src/gnutls.c index a7ef59ab919..67d1fb9552d 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -140,6 +140,7 @@ DEF_DLL_FN (void, gnutls_dh_set_prime_bits, | |||
| 140 | DEF_DLL_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); | 140 | DEF_DLL_FN (int, gnutls_dh_get_prime_bits, (gnutls_session_t)); |
| 141 | DEF_DLL_FN (int, gnutls_error_is_fatal, (int)); | 141 | DEF_DLL_FN (int, gnutls_error_is_fatal, (int)); |
| 142 | DEF_DLL_FN (int, gnutls_global_init, (void)); | 142 | DEF_DLL_FN (int, gnutls_global_init, (void)); |
| 143 | DEF_DLL_FN (void, gnutls_free, (void *)); | ||
| 143 | DEF_DLL_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); | 144 | DEF_DLL_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); |
| 144 | # ifdef HAVE_GNUTLS3 | 145 | # ifdef HAVE_GNUTLS3 |
| 145 | DEF_DLL_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); | 146 | DEF_DLL_FN (void, gnutls_global_set_audit_log_function, (gnutls_audit_log_func)); |
| @@ -326,6 +327,7 @@ init_gnutls_functions (void) | |||
| 326 | LOAD_DLL_FN (library, gnutls_dh_get_prime_bits); | 327 | LOAD_DLL_FN (library, gnutls_dh_get_prime_bits); |
| 327 | LOAD_DLL_FN (library, gnutls_error_is_fatal); | 328 | LOAD_DLL_FN (library, gnutls_error_is_fatal); |
| 328 | LOAD_DLL_FN (library, gnutls_global_init); | 329 | LOAD_DLL_FN (library, gnutls_global_init); |
| 330 | LOAD_DLL_FN (library, gnutls_free); | ||
| 329 | LOAD_DLL_FN (library, gnutls_global_set_log_function); | 331 | LOAD_DLL_FN (library, gnutls_global_set_log_function); |
| 330 | # ifdef HAVE_GNUTLS3 | 332 | # ifdef HAVE_GNUTLS3 |
| 331 | LOAD_DLL_FN (library, gnutls_global_set_audit_log_function); | 333 | LOAD_DLL_FN (library, gnutls_global_set_audit_log_function); |
| @@ -463,6 +465,7 @@ init_gnutls_functions (void) | |||
| 463 | # define gnutls_global_init fn_gnutls_global_init | 465 | # define gnutls_global_init fn_gnutls_global_init |
| 464 | # define gnutls_global_set_audit_log_function fn_gnutls_global_set_audit_log_function | 466 | # define gnutls_global_set_audit_log_function fn_gnutls_global_set_audit_log_function |
| 465 | # define gnutls_global_set_log_function fn_gnutls_global_set_log_function | 467 | # define gnutls_global_set_log_function fn_gnutls_global_set_log_function |
| 468 | # define gnutls_free fn_gnutls_free | ||
| 466 | # define gnutls_global_set_log_level fn_gnutls_global_set_log_level | 469 | # define gnutls_global_set_log_level fn_gnutls_global_set_log_level |
| 467 | # define gnutls_handshake fn_gnutls_handshake | 470 | # define gnutls_handshake fn_gnutls_handshake |
| 468 | # define gnutls_init fn_gnutls_init | 471 | # define gnutls_init fn_gnutls_init |
| @@ -1613,7 +1616,7 @@ string representation. */) | |||
| 1613 | memset (out_buf, 0, (out.size + 1) * sizeof (char)); | 1616 | memset (out_buf, 0, (out.size + 1) * sizeof (char)); |
| 1614 | memcpy (out_buf, out.data, out.size); | 1617 | memcpy (out_buf, out.data, out.size); |
| 1615 | 1618 | ||
| 1616 | xfree (out.data); | 1619 | gnutls_free (out.data); |
| 1617 | gnutls_x509_crt_deinit (crt); | 1620 | gnutls_x509_crt_deinit (crt); |
| 1618 | 1621 | ||
| 1619 | Lisp_Object result = build_string (out_buf); | 1622 | Lisp_Object result = build_string (out_buf); |