aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-08-23 01:11:12 -0700
committerPaul Eggert2019-08-23 01:12:22 -0700
commit49a8c8506a8477fd27ba924f14aa196e0d0813f9 (patch)
tree6f8d118d37bdc16b27e191fa61979eda79cb7b38 /src
parent27988f136c35396e0ef1e865f5a0c0a0bf20358a (diff)
downloademacs-49a8c8506a8477fd27ba924f14aa196e0d0813f9.tar.gz
emacs-49a8c8506a8477fd27ba924f14aa196e0d0813f9.zip
Get the Gnutls code compiling on Fedora 30
The recent changes caused the build to fail on Fedora 30 when built with --enable-gcc-warnings, among other things with diagnostics that gnutls_compression_get and gnutls_compression_get_name are deprecated (this started with GnuTLS 3.6). Fix this by refusing to call these obsolescent and now-dummy functions in GnuTLS 3.6 and later. However, this is just a temporary workaround to get the build working; a real fix is needed, as network-stream-tests fail. * src/gnutls.c (HAVE_GNUTLS_COMPRESSION_GET): New macro. (gnutls_compression_get, gnutls_compression_get_name): Define only if HAVE_GNUTLS_COMPRESSION_GET. (init_gnutls_functions): Load the two functions only if HAVE_GNUTLS_COMPRESSION_GET. (emacs_gnutls_certificate_export_pem): Use alloca instead of xmalloc. (Fgnutls_peer_status): Just return "NULL" if the functions are deprecated. (Fgnutls_format_certificate): Fix pointer signedness glitches. * src/process.c: Fix spacing.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c60
-rw-r--r--src/process.c26
2 files changed, 48 insertions, 38 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index db452e01aa6..51536b14632 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -48,6 +48,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
48# define HAVE_GNUTLS_ETM_STATUS 48# define HAVE_GNUTLS_ETM_STATUS
49#endif 49#endif
50 50
51#if GNUTLS_VERSION_NUMBER < 0x030600
52# define HAVE_GNUTLS_COMPRESSION_GET
53#endif
54
51/* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was 55/* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was
52 exported only since 3.3.0. */ 56 exported only since 3.3.0. */
53#if GNUTLS_VERSION_NUMBER >= 0x030300 57#if GNUTLS_VERSION_NUMBER >= 0x030300
@@ -217,10 +221,12 @@ DEF_DLL_FN (const char *, gnutls_cipher_get_name,
217 (gnutls_cipher_algorithm_t)); 221 (gnutls_cipher_algorithm_t));
218DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); 222DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t));
219DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); 223DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t));
224#ifdef HAVE_GNUTLS_COMPRESSION_GET
220DEF_DLL_FN (gnutls_compression_method_t, gnutls_compression_get, 225DEF_DLL_FN (gnutls_compression_method_t, gnutls_compression_get,
221 (gnutls_session_t)); 226 (gnutls_session_t));
222DEF_DLL_FN (const char *, gnutls_compression_get_name, 227DEF_DLL_FN (const char *, gnutls_compression_get_name,
223 (gnutls_compression_method_t)); 228 (gnutls_compression_method_t));
229#endif
224DEF_DLL_FN (unsigned, gnutls_safe_renegotiation_status, (gnutls_session_t)); 230DEF_DLL_FN (unsigned, gnutls_safe_renegotiation_status, (gnutls_session_t));
225 231
226# ifdef HAVE_GNUTLS3 232# ifdef HAVE_GNUTLS3
@@ -368,8 +374,10 @@ init_gnutls_functions (void)
368 LOAD_DLL_FN (library, gnutls_cipher_get_name); 374 LOAD_DLL_FN (library, gnutls_cipher_get_name);
369 LOAD_DLL_FN (library, gnutls_mac_get); 375 LOAD_DLL_FN (library, gnutls_mac_get);
370 LOAD_DLL_FN (library, gnutls_mac_get_name); 376 LOAD_DLL_FN (library, gnutls_mac_get_name);
377# ifdef HAVE_GNUTLS_COMPRESSION_GET
371 LOAD_DLL_FN (library, gnutls_compression_get); 378 LOAD_DLL_FN (library, gnutls_compression_get);
372 LOAD_DLL_FN (library, gnutls_compression_get_name); 379 LOAD_DLL_FN (library, gnutls_compression_get_name);
380# endif
373 LOAD_DLL_FN (library, gnutls_safe_renegotiation_status); 381 LOAD_DLL_FN (library, gnutls_safe_renegotiation_status);
374# ifdef HAVE_GNUTLS3 382# ifdef HAVE_GNUTLS3
375 LOAD_DLL_FN (library, gnutls_rnd); 383 LOAD_DLL_FN (library, gnutls_rnd);
@@ -462,8 +470,10 @@ init_gnutls_functions (void)
462# define gnutls_kx_get_name fn_gnutls_kx_get_name 470# define gnutls_kx_get_name fn_gnutls_kx_get_name
463# define gnutls_mac_get fn_gnutls_mac_get 471# define gnutls_mac_get fn_gnutls_mac_get
464# define gnutls_mac_get_name fn_gnutls_mac_get_name 472# define gnutls_mac_get_name fn_gnutls_mac_get_name
465# define gnutls_compression_get fn_gnutls_compression_get 473# ifdef HAVE_GNUTLS_COMPRESSION_GET
466# define gnutls_compression_get_name fn_gnutls_compression_get_name 474# define gnutls_compression_get fn_gnutls_compression_get
475# define gnutls_compression_get_name fn_gnutls_compression_get_name
476# endif
467# define gnutls_safe_renegotiation_status fn_gnutls_safe_renegotiation_status 477# define gnutls_safe_renegotiation_status fn_gnutls_safe_renegotiation_status
468# define gnutls_pk_algorithm_get_name fn_gnutls_pk_algorithm_get_name 478# define gnutls_pk_algorithm_get_name fn_gnutls_pk_algorithm_get_name
469# define gnutls_pk_bits_to_sec_param fn_gnutls_pk_bits_to_sec_param 479# define gnutls_pk_bits_to_sec_param fn_gnutls_pk_bits_to_sec_param
@@ -1082,17 +1092,18 @@ emacs_gnutls_certificate_export_pem (gnutls_x509_crt_t cert)
1082 1092
1083 if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) 1093 if (err == GNUTLS_E_SHORT_MEMORY_BUFFER)
1084 { 1094 {
1085 unsigned char *buf = xmalloc(size * sizeof (unsigned char)); 1095 USE_SAFE_ALLOCA;
1096 char *buf = SAFE_ALLOCA (size);
1086 err = gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_PEM, buf, &size); 1097 err = gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_PEM, buf, &size);
1087 check_memory_full (err); 1098 check_memory_full (err);
1088 1099
1089 if (err < GNUTLS_E_SUCCESS) 1100 if (err < GNUTLS_E_SUCCESS)
1090 { 1101 error ("GnuTLS certificate export error: %s",
1091 xfree (buf); 1102 emacs_gnutls_strerror (err));
1092 error ("GnuTLS certificate export error: %s", emacs_gnutls_strerror (err));
1093 }
1094 1103
1095 return build_string(buf); 1104 Lisp_Object result = build_string (buf);
1105 SAFE_FREE ();
1106 return result;
1096 } 1107 }
1097 else if (err < GNUTLS_E_SUCCESS) 1108 else if (err < GNUTLS_E_SUCCESS)
1098 error ("GnuTLS certificate export error: %s", emacs_gnutls_strerror (err)); 1109 error ("GnuTLS certificate export error: %s", emacs_gnutls_strerror (err));
@@ -1481,20 +1492,21 @@ returned as the :certificate entry. */)
1481 (gnutls_mac_get (state))))); 1492 (gnutls_mac_get (state)))));
1482 1493
1483 /* Compression name. */ 1494 /* Compression name. */
1484 result = nconc2 1495#ifdef HAVE_GNUTLS_COMPRESSION_GET
1485 (result, list2 (intern (":compression"), 1496 Lisp_Object compression = build_string (gnutls_compression_get_name
1486 build_string (gnutls_compression_get_name 1497 (gnutls_compression_get (state)));
1487 (gnutls_compression_get (state))))); 1498#else
1499 Lisp_Object compression = build_string ("NULL");
1500#endif
1501 result = nconc2 (result, list2 (intern (":compression"), compression));
1488 1502
1489 /* Encrypt-then-MAC. */ 1503 /* Encrypt-then-MAC. */
1490 result = nconc2 1504 Lisp_Object etm_status = Qnil;
1491 (result, list2 (intern (":encrypt-then-mac"),
1492#ifdef HAVE_GNUTLS_ETM_STATUS 1505#ifdef HAVE_GNUTLS_ETM_STATUS
1493 gnutls_session_etm_status (state) ? Qt : Qnil 1506 if (gnutls_session_etm_status (state))
1494#else 1507 etm_status = Qt;
1495 Qnil
1496#endif 1508#endif
1497 )); 1509 result = nconc2 (result, list2 (intern (":encrypt-then-mac"), etm_status));
1498 1510
1499 /* Renegotiation Indication */ 1511 /* Renegotiation Indication */
1500 result = nconc2 1512 result = nconc2
@@ -1561,7 +1573,8 @@ boot_error (struct Lisp_Process *p, const char *m, ...)
1561 va_end (ap); 1573 va_end (ap);
1562} 1574}
1563 1575
1564DEFUN ("gnutls-format-certificate", Fgnutls_format_certificate, Sgnutls_format_certificate, 1, 1, 0, 1576DEFUN ("gnutls-format-certificate", Fgnutls_format_certificate,
1577 Sgnutls_format_certificate, 1, 1, 0,
1565 doc: /* Format a X.509 certificate to a string. 1578 doc: /* Format a X.509 certificate to a string.
1566 1579
1567Given a PEM-encoded X.509 certificate CERT, returns a human-readable 1580Given a PEM-encoded X.509 certificate CERT, returns a human-readable
@@ -1578,14 +1591,14 @@ string representation. */)
1578 if (err < GNUTLS_E_SUCCESS) 1591 if (err < GNUTLS_E_SUCCESS)
1579 error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); 1592 error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err));
1580 1593
1581 unsigned char *crt_buf = SDATA (cert); 1594 gnutls_datum_t crt_data = { SDATA (cert), strlen (SSDATA (cert)) };
1582 gnutls_datum_t crt_data = { crt_buf, strlen (crt_buf) };
1583 err = gnutls_x509_crt_import (crt, &crt_data, GNUTLS_X509_FMT_PEM); 1595 err = gnutls_x509_crt_import (crt, &crt_data, GNUTLS_X509_FMT_PEM);
1584 check_memory_full (err); 1596 check_memory_full (err);
1585 if (err < GNUTLS_E_SUCCESS) 1597 if (err < GNUTLS_E_SUCCESS)
1586 { 1598 {
1587 gnutls_x509_crt_deinit (crt); 1599 gnutls_x509_crt_deinit (crt);
1588 error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); 1600 error ("gnutls-format-certificate error: %s",
1601 emacs_gnutls_strerror (err));
1589 } 1602 }
1590 1603
1591 gnutls_datum_t out; 1604 gnutls_datum_t out;
@@ -1594,7 +1607,8 @@ string representation. */)
1594 if (err < GNUTLS_E_SUCCESS) 1607 if (err < GNUTLS_E_SUCCESS)
1595 { 1608 {
1596 gnutls_x509_crt_deinit (crt); 1609 gnutls_x509_crt_deinit (crt);
1597 error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); 1610 error ("gnutls-format-certificate error: %s",
1611 emacs_gnutls_strerror (err));
1598 } 1612 }
1599 1613
1600 char *out_buf = xmalloc ((out.size + 1) * sizeof (char)); 1614 char *out_buf = xmalloc ((out.size + 1) * sizeof (char));
diff --git a/src/process.c b/src/process.c
index 7097b7ace17..c3cc78afa28 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4120,10 +4120,8 @@ usage: (make-network-process &rest ARGS) */)
4120 hints.ai_socktype = socktype; 4120 hints.ai_socktype = socktype;
4121 4121
4122 msg = network_lookup_address_info_1 (host, portstring, &hints, &res); 4122 msg = network_lookup_address_info_1 (host, portstring, &hints, &res);
4123 if (!EQ(msg, Qt)) 4123 if (!EQ (msg, Qt))
4124 { 4124 error ("%s", SSDATA (msg));
4125 error ("%s", SSDATA (msg));
4126 }
4127 4125
4128 for (lres = res; lres; lres = lres->ai_next) 4126 for (lres = res; lres; lres = lres->ai_next)
4129 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); 4127 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos);
@@ -4593,10 +4591,12 @@ network_lookup_address_info_1 (Lisp_Object host, const char *service,
4593 str = SSDATA (code_convert_string_norecord 4591 str = SSDATA (code_convert_string_norecord
4594 (build_string (str), Vlocale_coding_system, 0)); 4592 (build_string (str), Vlocale_coding_system, 0));
4595 AUTO_STRING (format, "%s/%s %s"); 4593 AUTO_STRING (format, "%s/%s %s");
4596 msg = CALLN (Fformat, format, host, build_string (service), build_string (str)); 4594 msg = CALLN (Fformat, format, host, build_string (service),
4595 build_string (str));
4597#else 4596#else
4598 AUTO_STRING (format, "%s/%s getaddrinfo error %d"); 4597 AUTO_STRING (format, "%s/%s getaddrinfo error %d");
4599 msg = CALLN (Fformat, format, host, build_string (service), make_number (ret)); 4598 msg = CALLN (Fformat, format, host, build_string (service),
4599 make_number (ret));
4600#endif 4600#endif
4601 } 4601 }
4602 return msg; 4602 return msg;
@@ -4634,18 +4634,14 @@ nil if none were found. Each address is a vector of integers. */)
4634 hints.ai_socktype = SOCK_DGRAM; 4634 hints.ai_socktype = SOCK_DGRAM;
4635 4635
4636 msg = network_lookup_address_info_1 (name, NULL, &hints, &res); 4636 msg = network_lookup_address_info_1 (name, NULL, &hints, &res);
4637 if (!EQ(msg, Qt)) 4637 if (!EQ (msg, Qt))
4638 { 4638 message ("%s", SSDATA(msg));
4639 message ("%s", SSDATA(msg));
4640 }
4641 else 4639 else
4642 { 4640 {
4643 for (lres = res; lres; lres = lres->ai_next) 4641 for (lres = res; lres; lres = lres->ai_next)
4644 { 4642 addresses = Fcons (conv_sockaddr_to_lisp (lres->ai_addr,
4645 addresses = Fcons (conv_sockaddr_to_lisp 4643 lres->ai_addrlen),
4646 (lres->ai_addr, lres->ai_addrlen), 4644 addresses);
4647 addresses);
4648 }
4649 addresses = Fnreverse (addresses); 4645 addresses = Fnreverse (addresses);
4650 4646
4651 freeaddrinfo (res); 4647 freeaddrinfo (res);