From 534a3d5d3a99a6b86a47b3d91840ce8771ee0ae6 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Tue, 10 Jul 2018 14:20:09 +0100 Subject: Revamp Network Security manager checks for TLS * lisp/net/nsm.el (network-security-level, nsm-level, nsm-new-fingerprint-ok-p): Remove `paranoid' level and related code. * lisp/net/nsm.el (nsm-tls-checks, nsm-tls-check-version, nsm-tls-check-compression, nsm-tls-check-renegotiation-info-ext, nsm-tls-check-verify-cert, nsm-tls-check-same-cert, nsm-tls-check-null-suite, nsm-tls-check-export-kx, nsm-tls-check-anon-kx, nsm-tls-check-md5-sig, nsm-tls-check-rc4-cipher, nsm-tls-check-dhe-prime-kx, nsm-tls-check-sha1-sig, nsm-tls-check-ecdsa-cbc-cipher nsm-tls-check-dhe-kx, nsm-tls-check-rsa-kx, nsm-tls-check-3des-cipher, nsm-tls-check-cbc-cipher, nsm-save-fingerprint-maybe, nsm-tls-post-check-functions): New options and functions for checking TLS handshake problems. * lisp/net/nsm.el (nsm-check-certificate, network-security-protocol-checks, nsm-protocol-check--diffie-hellman-prime-bits, nsm-protocol-check--3des, nsm-protocol-check--rc4, nsm-protocol-check--signature-sha1, nsm-protocol-check--intermediate-sha1, nsm-protocol-check--ssl, nsm-check-protocol): Remove in favor of `nsm-tls-checks' and `nsm-tls-check-*' functions. * lisp/net/nsm.el (nsm-verify-connection): Ensure connection is checked even when `network-security-level' is `low'. * lisp/net/nsm.el (nsm-check-tls-connection): Batch all problems found before querying the user. * lisp/net/nsm.el (nsm--encryption): Renamed to `nsm-cipher-suite'. * lisp/net/nsm.el (nsm-fingerprint-ok-p): No longer prompt when certificate fingerprints mismatch. Returns a boolean instead when the fingerprint of the certificate received matches the saved fingerprints. * lisp/net/nsm.el (nsm-query): Change signature. Accepts a list of problems and a preformatted message instead of just a message format and the arguments for the message. * lisp/net/nsm.el (nsm-query-user): Change signature. Accepts a preformatted message and the peer status of the handshake instead of a message format, its arguments and the certificate for the host. * lisp/net/nsm.el (nsm-save-host): Change signature. Accepts a list of problems after the WHAT parameter. Saves multiple fingerprints for the same host in case the host load balances a TLS server with more than one certificates signed with different keys. Makes sure conditions are not removed when updating a fingerprint. * lisp/net/nsm.el (nsm-format-certificate): Display the TLS handshake's renegotiation info extension, compression level, encrypt-then-MAC extension, and key exchange prime bit length. * src/gnutls.c (gnutls-peer-status-warning-describe, gnutls-peer-status): Check for certificate verification problems introduced since GnuTLS 3.1. * src/gnutls.c (gnutls-peer-status): `:compression', `:encrypt-then-mac' and `:safe-renegotiation' are now contained in the peer status result return value. --- src/gnutls.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'src') diff --git a/src/gnutls.c b/src/gnutls.c index d7a4ee474f7..448f6732e6b 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -40,6 +40,10 @@ along with GNU Emacs. If not, see . */ # define HAVE_GNUTLS_AEAD #endif +#if GNUTLS_VERSION_NUMBER >= 0x030400 +# define HAVE_GNUTLS_ETM_STATUS +#endif + /* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was exported only since 3.3.0. */ #if GNUTLS_VERSION_NUMBER >= 0x030300 @@ -197,6 +201,11 @@ DEF_DLL_FN (const char *, gnutls_cipher_get_name, (gnutls_cipher_algorithm_t)); DEF_DLL_FN (gnutls_mac_algorithm_t, gnutls_mac_get, (gnutls_session_t)); DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t)); +DEF_DLL_FN (gnutls_compression_method_t, gnutls_compression_get, + (gnutls_session_t)); +DEF_DLL_FN (const char *, gnutls_compression_get_name, + (gnutls_compression_method_t)); +DEF_DLL_FN (unsigned, gnutls_safe_renegotiation_status, (gnutls_session_t)); # ifdef HAVE_GNUTLS3 DEF_DLL_FN (int, gnutls_rnd, (gnutls_rnd_level_t, void *, size_t)); @@ -233,6 +242,9 @@ DEF_DLL_FN (int, gnutls_aead_cipher_decrypt, (gnutls_aead_cipher_hd_t, const void *, size_t, const void *, size_t, size_t, const void *, size_t, void *, size_t *)); # endif +# ifdef HAVE_GNUTLS_ETM_STATUS +DEF_DLL_FN (unsigned, gnutls_session_etm_status, (gnutls_session_t)); +# endif DEF_DLL_FN (int, gnutls_hmac_init, (gnutls_hmac_hd_t *, gnutls_mac_algorithm_t, const void *, size_t)); DEF_DLL_FN (int, gnutls_hmac_get_len, (gnutls_mac_algorithm_t)); @@ -332,6 +344,9 @@ init_gnutls_functions (void) LOAD_DLL_FN (library, gnutls_cipher_get_name); LOAD_DLL_FN (library, gnutls_mac_get); LOAD_DLL_FN (library, gnutls_mac_get_name); + LOAD_DLL_FN (library, gnutls_compression_get); + LOAD_DLL_FN (library, gnutls_compression_get_name); + LOAD_DLL_FN (library, gnutls_safe_renegotiation_status); # ifdef HAVE_GNUTLS3 LOAD_DLL_FN (library, gnutls_rnd); LOAD_DLL_FN (library, gnutls_mac_list); @@ -356,6 +371,9 @@ init_gnutls_functions (void) LOAD_DLL_FN (library, gnutls_aead_cipher_deinit); LOAD_DLL_FN (library, gnutls_aead_cipher_encrypt); LOAD_DLL_FN (library, gnutls_aead_cipher_decrypt); +# endif +# ifdef HAVE_GNUTLS_ETM_STATUS + LOAD_DLL_FN (library, gnutls_session_etm_status); # endif LOAD_DLL_FN (library, gnutls_hmac_init); LOAD_DLL_FN (library, gnutls_hmac_get_len); @@ -415,6 +433,9 @@ init_gnutls_functions (void) # define gnutls_kx_get_name fn_gnutls_kx_get_name # define gnutls_mac_get fn_gnutls_mac_get # define gnutls_mac_get_name fn_gnutls_mac_get_name +# define gnutls_compression_get fn_gnutls_compression_get +# define gnutls_compression_get_name fn_gnutls_compression_get_name +# define gnutls_safe_renegotiation_status fn_gnutls_safe_renegotiation_status; # define gnutls_pk_algorithm_get_name fn_gnutls_pk_algorithm_get_name # define gnutls_pk_bits_to_sec_param fn_gnutls_pk_bits_to_sec_param # define gnutls_priority_set_direct fn_gnutls_priority_set_direct @@ -473,6 +494,9 @@ init_gnutls_functions (void) # define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init # define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit # endif +# ifdef HAVE_GNUTLS_ETM_STATUS +# define gnutls_session_etm_status fn_gnutls_session_etm_status +# endif # define gnutls_hmac_init fn_gnutls_hmac_init # define gnutls_hmac_get_len fn_gnutls_hmac_get_len # define gnutls_hmac fn_gnutls_hmac @@ -1205,6 +1229,29 @@ DEFUN ("gnutls-peer-status-warning-describe", Fgnutls_peer_status_warning_descri if (EQ (status_symbol, intern (":no-host-match"))) return build_string ("certificate host does not match hostname"); + if (EQ (status_symbol, intern (":signature-failure"))) + return build_string ("certificate signature could not be verified"); + + if (EQ (status_symbol, intern (":revocation-data-superseded"))) + return build_string ("certificate revocation data are old and have been " + "superseded"); + + if (EQ (status_symbol, intern (":revocation-data-issued-in-future"))) + return build_string ("certificate revocation data have a future issue date"); + + if (EQ (status_symbol, intern (":signer-constraints-failure"))) + return build_string ("certificate "); + + if (EQ (status_symbol, intern (":purpose-mismatch"))) + return build_string ("certificate does not match the intended purpose"); + + if (EQ (status_symbol, intern (":missing-ocsp-status"))) + return build_string ("certificate requires the server to send a OCSP " + "certificate status, but no status was received"); + + if (EQ (status_symbol, intern (":invalid-ocsp-status"))) + return build_string ("the received OCSP certificate status is invalid"); + return Qnil; } @@ -1256,6 +1303,35 @@ returned as the :certificate entry. */) if (verification & GNUTLS_CERT_EXPIRED) warnings = Fcons (intern (":expired"), warnings); +#if GNUTLS_VERSION_NUMBER >= 0x030100 + if (verification & GNUTLS_CERT_SIGNATURE_FAILURE) + warnings = Fcons (intern (":signature-failure"), warnings); + +# if GNUTLS_VERSION_NUMBER >= 0x030114 + if (verification & GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED) + warnings = Fcons (intern (":revocation-data-superseded"), warnings); + + if (verification & GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE) + warnings = Fcons (intern (":revocation-data-issued-in-future"), warnings); + + if (verification & GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE) + warnings = Fcons (intern (":signer-constraints-failure"), warnings); + +# if GNUTLS_VERSION_NUMBER >= 0x030400 + if (verification & GNUTLS_CERT_PURPOSE_MISMATCH) + warnings = Fcons (intern (":purpose-mismatch"), warnings); + +# if GNUTLS_VERSION_NUMBER >= 0x030501 + if (verification & GNUTLS_CERT_MISSING_OCSP_STATUS) + warnings = Fcons (intern (":missing-ocsp-status"), warnings); + + if (verification & GNUTLS_CERT_INVALID_OCSP_STATUS) + warnings = Fcons (intern (":invalid-ocsp-status"), warnings); +# endif +# endif +# endif +#endif + if (XPROCESS (proc)->gnutls_extra_peer_verification & CERTIFICATE_NOT_MATCHING) warnings = Fcons (intern (":no-host-match"), warnings); @@ -1323,6 +1399,26 @@ returned as the :certificate entry. */) build_string (gnutls_mac_get_name (gnutls_mac_get (state))))); + /* Compression name. */ + result = nconc2 + (result, list2 (intern (":compression"), + build_string (gnutls_compression_get_name + (gnutls_compression_get (state))))); + + /* Encrypt-then-MAC. */ + result = nconc2 + (result, list2 (intern (":encrypt-then-mac"), +#ifdef HAVE_GNUTLS_ETM_STATUS + gnutls_session_etm_status (state) ? Qt : Qnil +#else + Qnil +#endif + )); + + /* Renegotiation Indication */ + result = nconc2 + (result, list2 (intern (":safe-renegotiation"), + gnutls_safe_renegotiation_status (state) ? Qt : Qnil)); return result; } -- cgit v1.2.1 From 87484dc27ec7a6e708c7e0ceaf96bff1ee064174 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Tue, 10 Jul 2018 18:38:11 +0100 Subject: Full certificate chain details for NSM * lisp/net/nsm.el (nsm-check-tls-connection): Fix issue with plural problems in message. Prefix every problem with a bullet. (nsm-query-user): Add new view the full certificate chain by pressing d. (nsm-format-certificate): Improve basic certificate and session info formatting. * src/gnutls.c (emacs_gnutls_certificate_export_pem): New function. (gnutls_certificate_details): Rename to emacs_gnutls_certificate_details. Add :pem to result list. (Fgnutls_format_certificate): New function for formatting a PEM to human-readable text. --- src/gnutls.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gnutls.c b/src/gnutls.c index 448f6732e6b..117278df35b 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -152,6 +152,8 @@ DEF_DLL_FN (int, gnutls_x509_crt_check_hostname, DEF_DLL_FN (int, gnutls_x509_crt_check_issuer, (gnutls_x509_crt_t, gnutls_x509_crt_t)); DEF_DLL_FN (void, gnutls_x509_crt_deinit, (gnutls_x509_crt_t)); +DEF_DLL_DN (int, gnutls_x509_crt_export, + (gnutls_x509_crt_t, gnutls_x509_crt_fmt_t, void *, size_t *)); DEF_DLL_FN (int, gnutls_x509_crt_import, (gnutls_x509_crt_t, const gnutls_datum_t *, gnutls_x509_crt_fmt_t)); @@ -173,6 +175,9 @@ DEF_DLL_FN (int, gnutls_x509_crt_get_dn, (gnutls_x509_crt_t, char *, size_t *)); DEF_DLL_FN (int, gnutls_x509_crt_get_pk_algorithm, (gnutls_x509_crt_t, unsigned int *)); +DEF_DLL_FN (int, gnutls_x509_crt_print, + (gnutls_x509_crt_t, gnutls_certificate_print_formats_t, + gnutls_datum_t *)); DEF_DLL_FN (const char *, gnutls_pk_algorithm_get_name, (gnutls_pk_algorithm_t)); DEF_DLL_FN (int, gnutls_pk_bits_to_sec_param, @@ -317,6 +322,7 @@ init_gnutls_functions (void) LOAD_DLL_FN (library, gnutls_x509_crt_check_hostname); LOAD_DLL_FN (library, gnutls_x509_crt_check_issuer); LOAD_DLL_FN (library, gnutls_x509_crt_deinit); + LOAD_DLL_FN (library, gnutls_x509_crt_export); LOAD_DLL_FN (library, gnutls_x509_crt_import); LOAD_DLL_FN (library, gnutls_x509_crt_init); LOAD_DLL_FN (library, gnutls_x509_crt_get_fingerprint); @@ -327,6 +333,7 @@ init_gnutls_functions (void) LOAD_DLL_FN (library, gnutls_x509_crt_get_expiration_time); LOAD_DLL_FN (library, gnutls_x509_crt_get_dn); LOAD_DLL_FN (library, gnutls_x509_crt_get_pk_algorithm); + LOAD_DLL_FN (library, gnutls_x509_crt_print) LOAD_DLL_FN (library, gnutls_pk_algorithm_get_name); LOAD_DLL_FN (library, gnutls_pk_bits_to_sec_param); LOAD_DLL_FN (library, gnutls_x509_crt_get_issuer_unique_id); @@ -455,6 +462,7 @@ init_gnutls_functions (void) # define gnutls_x509_crt_check_hostname fn_gnutls_x509_crt_check_hostname # define gnutls_x509_crt_check_issuer fn_gnutls_x509_crt_check_issuer # define gnutls_x509_crt_deinit fn_gnutls_x509_crt_deinit +# define gnutls_x509_crt_export fn_gnutls_x509_crt_export # define gnutls_x509_crt_get_activation_time fn_gnutls_x509_crt_get_activation_time # define gnutls_x509_crt_get_dn fn_gnutls_x509_crt_get_dn # define gnutls_x509_crt_get_expiration_time fn_gnutls_x509_crt_get_expiration_time @@ -463,6 +471,7 @@ init_gnutls_functions (void) # define gnutls_x509_crt_get_issuer_unique_id fn_gnutls_x509_crt_get_issuer_unique_id # define gnutls_x509_crt_get_key_id fn_gnutls_x509_crt_get_key_id # define gnutls_x509_crt_get_pk_algorithm fn_gnutls_x509_crt_get_pk_algorithm +# define gnutls_x509_crt_print fn_gnutls_x509_crt_print # define gnutls_x509_crt_get_serial fn_gnutls_x509_crt_get_serial # define gnutls_x509_crt_get_signature_algorithm fn_gnutls_x509_crt_get_signature_algorithm # define gnutls_x509_crt_get_subject_unique_id fn_gnutls_x509_crt_get_subject_unique_id @@ -1024,7 +1033,34 @@ gnutls_hex_string (unsigned char *buf, ptrdiff_t buf_size, const char *prefix) } static Lisp_Object -gnutls_certificate_details (gnutls_x509_crt_t cert) +emacs_gnutls_certificate_export_pem (gnutls_x509_crt_t cert) +{ + size_t size = 0; + int err = gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_PEM, NULL, &size); + check_memory_full (err); + + if (err == GNUTLS_E_SHORT_MEMORY_BUFFER) + { + unsigned char *buf = xmalloc(size * sizeof (unsigned char)); + err = gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_PEM, buf, &size); + check_memory_full (err); + + if (err < GNUTLS_E_SUCCESS) + { + xfree (buf); + error ("GnuTLS certificate export error: %s", emacs_gnutls_strerror (err)); + } + + return build_string(buf); + } + else if (err < GNUTLS_E_SUCCESS) + error ("GnuTLS certificate export error: %s", emacs_gnutls_strerror (err)); + + return Qnil; +} + +static Lisp_Object +emacs_gnutls_certificate_details (gnutls_x509_crt_t cert) { Lisp_Object res = Qnil; int err; @@ -1192,6 +1228,10 @@ gnutls_certificate_details (gnutls_x509_crt_t cert) xfree (buf); } + /* PEM */ + res = nconc2 (res, list2 (intern (":pem"), + emacs_gnutls_certificate_export_pem(cert))); + return res; } @@ -1354,7 +1394,7 @@ returned as the :certificate entry. */) /* Return all the certificates in a list. */ for (int i = 0; i < XPROCESS (proc)->gnutls_certificates_length; i++) - certs = nconc2 (certs, list1 (gnutls_certificate_details + certs = nconc2 (certs, list1 (emacs_gnutls_certificate_details (XPROCESS (proc)->gnutls_certificates[i]))); result = nconc2 (result, list2 (intern (":certificates"), certs)); @@ -1480,6 +1520,55 @@ boot_error (struct Lisp_Process *p, const char *m, ...) va_end (ap); } +DEFUN ("gnutls-format-certificate", Fgnutls_format_certificate, Sgnutls_format_certificate, 1, 1, 0, + doc: /* Format a X.509 certificate to a string. + +Given a PEM-encoded X.509 certificate CERT, returns a human-readable +string representation. */) + (Lisp_Object cert) +{ + CHECK_STRING (cert); + + int err; + gnutls_x509_crt_t crt; + + err = gnutls_x509_crt_init (&crt); + check_memory_full (err); + if (err < GNUTLS_E_SUCCESS) + error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); + + unsigned char *crt_buf = SDATA (cert); + gnutls_datum_t crt_data = { crt_buf, strlen (crt_buf) }; + err = gnutls_x509_crt_import (crt, &crt_data, GNUTLS_X509_FMT_PEM); + check_memory_full (err); + if (err < GNUTLS_E_SUCCESS) + { + gnutls_x509_crt_deinit (crt); + error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); + } + + gnutls_datum_t out; + err = gnutls_x509_crt_print (crt, GNUTLS_CRT_PRINT_FULL, &out); + check_memory_full (err); + if (err < GNUTLS_E_SUCCESS) + { + gnutls_x509_crt_deinit (crt); + error ("gnutls-format-certificate error: %s", emacs_gnutls_strerror (err)); + } + + char *out_buf = xmalloc ((out.size + 1) * sizeof (char)); + memset (out_buf, 0, (out.size + 1) * sizeof (char)); + memcpy (out_buf, out.data, out.size); + + xfree (out.data); + gnutls_x509_crt_deinit (crt); + + Lisp_Object result = build_string (out_buf); + xfree (out_buf); + + return result; +} + Lisp_Object gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist) { @@ -2713,6 +2802,7 @@ syms_of_gnutls (void) defsubr (&Sgnutls_bye); defsubr (&Sgnutls_peer_status); defsubr (&Sgnutls_peer_status_warning_describe); + defsubr (&Sgnutls_format_certificate); #ifdef HAVE_GNUTLS3 defsubr (&Sgnutls_ciphers); -- cgit v1.2.1 From e89c06e8cea429620bc2cf4a98b9b741861b811a Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Mon, 16 Jul 2018 19:43:41 +0200 Subject: Implement hostname->ip lookup function * src/process.c (conv_sockaddr_to_lisp): Add include_port argument. Don't put a port in the result if this is false. (conv_addrinfo_to_lisp, Fprocess_datagram_address) (connect_network_socket, network_interface_list) (network_interface_info, server_accept_connection) (init_process_emacs): Update callers. (Fnetwork_lookup_address_info): New function. Performs hostname to ip address lookups. * src/w32.c (network_interface_get_info): Update callers of conv_sockaddr_to_lisp * etc/NEWS : mention addition of 'network-lookup-address-info' --- src/process.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++--------- src/process.h | 2 +- src/w32.c | 24 +++++++++----- 3 files changed, 102 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/process.c b/src/process.c index 3fccd962da6..2025398c22d 100644 --- a/src/process.c +++ b/src/process.c @@ -2484,7 +2484,7 @@ usage: (make-pipe-process &rest ARGS) */) The address family of sa is not included in the result. */ Lisp_Object -conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) +conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len, bool include_port) { Lisp_Object address; ptrdiff_t i; @@ -2503,9 +2503,12 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) { DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa); len = sizeof (sin->sin_addr) + 1; + if (!include_port) + len--; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); - p->contents[--len] = make_number (ntohs (sin->sin_port)); + if (include_port) + p->contents[--len] = make_number (ntohs (sin->sin_port)); cp = (unsigned char *) &sin->sin_addr; break; } @@ -2515,9 +2518,12 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa); DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr); len = sizeof (sin6->sin6_addr) / 2 + 1; + if (!include_port) + len--; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); - p->contents[--len] = make_number (ntohs (sin6->sin6_port)); + if (include_port) + p->contents[--len] = make_number (ntohs (sin6->sin6_port)); for (i = 0; i < len; i++) p->contents[i] = make_number (ntohs (ip6[i])); return address; @@ -2568,7 +2574,7 @@ conv_addrinfo_to_lisp (struct addrinfo *res) { Lisp_Object protocol = make_number (res->ai_protocol); eassert (XINT (protocol) == res->ai_protocol); - return Fcons (protocol, conv_sockaddr_to_lisp (res->ai_addr, res->ai_addrlen)); + return Fcons (protocol, conv_sockaddr_to_lisp (res->ai_addr, res->ai_addrlen, true)); } @@ -2710,7 +2716,8 @@ set up yet, this function will block until socket setup has completed. */) channel = XPROCESS (process)->infd; return conv_sockaddr_to_lisp (datagram_address[channel].sa, - datagram_address[channel].len); + datagram_address[channel].len, + true); } DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_process_datagram_address, @@ -3571,7 +3578,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, #endif contact = Fplist_put (contact, p->is_server? QClocal: QCremote, - conv_sockaddr_to_lisp (sa, addrlen)); + conv_sockaddr_to_lisp (sa, addrlen, true)); #ifdef HAVE_GETSOCKNAME if (!p->is_server) { @@ -3580,7 +3587,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1); if (getsockname (s, psa1, &len1) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp (psa1, len1)); + conv_sockaddr_to_lisp (psa1, len1, true)); } #endif } @@ -4253,7 +4260,8 @@ network_interface_list (void) namebuf[sizeof (ifq->ifr_name)] = 0; res = Fcons (Fcons (build_string (namebuf), conv_sockaddr_to_lisp (&ifq->ifr_addr, - sizeof (struct sockaddr))), + sizeof (struct sockaddr), + true)), res); } @@ -4456,9 +4464,9 @@ network_interface_info (Lisp_Object ifname) { any = 1; #ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK - elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask)); + elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask), true); #else - elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); + elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr), true); #endif } #endif @@ -4469,7 +4477,7 @@ network_interface_info (Lisp_Object ifname) if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) { any = 1; - elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr)); + elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr), true); } #endif res = Fcons (elt, res); @@ -4479,7 +4487,7 @@ network_interface_info (Lisp_Object ifname) if (ioctl (s, SIOCGIFADDR, &rq) == 0) { any = 1; - elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); + elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr), true); } #endif res = Fcons (elt, res); @@ -4527,6 +4535,67 @@ Data that is unavailable is returned as nil. */) #endif } +DEFUN ("network-lookup-address-info", Fnetwork_lookup_address_info, + Snetwork_lookup_address_info, 1, 2, 0, + doc: /* Look up ip address info of NAME. +Optional parameter FAMILY controls whether to look up IPv4 or IPv6 +addresses. The default of nil means both, symbol `ipv4' means IPv4 +only, symbol `ipv6' means IPv6 only. Returns a list of addresses, or +nil if none were found. Each address is a vector of integers. */) + (Lisp_Object name, Lisp_Object family) +{ + Lisp_Object addresses = Qnil; + struct addrinfo *res, *lres; + int ret; + + struct addrinfo hints; + + if (STRING_MULTIBYTE (name)) + error ("Non-ASCII hostname \"%s\" detected, please use puny-encode-string", + SSDATA (name)); + memset (&hints, 0, sizeof hints); + if (EQ (family, Qnil)) + hints.ai_family = AF_UNSPEC; + if (EQ (family, Qipv4)) + hints.ai_family = AF_INET; + if (EQ (family, Qipv6)) +#ifdef AF_INET6 + hints.ai_family = AF_INET6; +#else + /* If we don't support IPv6, querying will never work anyway */ + return addresses; +#endif + hints.ai_socktype = SOCK_DGRAM; + + ret = getaddrinfo (SSDATA (name), NULL, &hints, &res); + if (ret) +#ifdef HAVE_GAI_STRERROR + { + synchronize_system_messages_locale (); + char const *str = gai_strerror (ret); + if (! NILP (Vlocale_coding_system)) + str = SSDATA (code_convert_string_norecord + (build_string (str), Vlocale_coding_system, 0)); + message ("\"%s\" \"%s\"", SSDATA (name), str); + } +#else + message ("%s network-lookup-address-info error %d", SSDATA (name), ret); +#endif + else + { + for (lres = res; lres; lres = lres->ai_next) + { + addresses = Fcons (conv_sockaddr_to_lisp + (lres->ai_addr, lres->ai_addrlen, false), + addresses); + } + addresses = Fnreverse (addresses); + + freeaddrinfo (res); + } + return addresses; +} + /* Turn off input and output for process PROC. */ static void @@ -4794,12 +4863,12 @@ server_accept_connection (Lisp_Object server, int channel) if (!NILP (service)) contact = Fplist_put (contact, QCservice, service); contact = Fplist_put (contact, QCremote, - conv_sockaddr_to_lisp (&saddr.sa, len)); + conv_sockaddr_to_lisp (&saddr.sa, len, true)); #ifdef HAVE_GETSOCKNAME len = sizeof saddr; if (getsockname (s, &saddr.sa, &len) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp (&saddr.sa, len)); + conv_sockaddr_to_lisp (&saddr.sa, len, true)); #endif pset_childp (p, contact); @@ -8031,7 +8100,7 @@ init_process_emacs (int sockfd) union u_sockaddr sa; socklen_t salen = sizeof sa; if (getsockname (sockfd, &sa.sa, &salen) == 0) - sockname = conv_sockaddr_to_lisp (&sa.sa, salen); + sockname = conv_sockaddr_to_lisp (&sa.sa, salen, true); } # endif Vinternal__daemon_sockname = sockname; @@ -8269,6 +8338,7 @@ returns non-`nil'. */); defsubr (&Sset_network_process_option); defsubr (&Smake_network_process); defsubr (&Sformat_network_address); + defsubr (&Snetwork_lookup_address_info); defsubr (&Snetwork_interface_list); defsubr (&Snetwork_interface_info); #ifdef DATAGRAM_SOCKETS diff --git a/src/process.h b/src/process.h index 6bc22146a72..504e5e6aaac 100644 --- a/src/process.h +++ b/src/process.h @@ -278,7 +278,7 @@ extern Lisp_Object system_process_attributes (Lisp_Object); extern void record_deleted_pid (pid_t, Lisp_Object); struct sockaddr; -extern Lisp_Object conv_sockaddr_to_lisp (struct sockaddr *, ptrdiff_t); +extern Lisp_Object conv_sockaddr_to_lisp (struct sockaddr *, ptrdiff_t, bool); extern void hold_keyboard_input (void); extern void unhold_keyboard_input (void); extern bool kbd_on_hold_p (void); diff --git a/src/w32.c b/src/w32.c index c848b33b2af..4759b082eb5 100644 --- a/src/w32.c +++ b/src/w32.c @@ -9210,7 +9210,8 @@ network_interface_get_info (Lisp_Object ifname) if (NILP (ifname)) res = Fcons (Fcons (build_string (namebuf), conv_sockaddr_to_lisp ((struct sockaddr*) &sa, - sizeof (struct sockaddr))), + sizeof (struct sockaddr), + false)), res); else if (strcmp (namebuf, SSDATA (ifname)) == 0) { @@ -9257,7 +9258,8 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = net_mask; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); } else @@ -9274,14 +9276,16 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = bcast_addr; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); /* IP address. */ sa.sin_addr.s_addr = ip_addr; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); } else @@ -9299,7 +9303,8 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = sys_inet_addr ("127.0.0.1"); res = Fcons (Fcons (build_string ("lo"), conv_sockaddr_to_lisp ((struct sockaddr*) &sa, - sizeof (struct sockaddr))), + sizeof (struct sockaddr), + false)), res); } else if (strcmp (SSDATA (ifname), "lo") == 0) @@ -9315,15 +9320,18 @@ network_interface_get_info (Lisp_Object ifname) res); sa.sin_addr.s_addr = sys_inet_addr ("255.0.0.0"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); sa.sin_addr.s_addr = sys_inet_addr ("0.0.0.0"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); sa.sin_addr.s_addr = sys_inet_addr ("127.0.0.1"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr)), + sizeof (struct sockaddr), + false), res); } -- cgit v1.2.1 From adff0d5f75d4b3a74816527edb9ebe997c2089f3 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 17 Jul 2018 13:08:12 +0200 Subject: Refactor getaddrinfo usage * src/process.c: (network_lookup_address_info_1): New function, does most of the work to call getaddrinfo. Now checks hostname for pure-ASCII. (Fmake_network_process): Use it. (Fnetwork_lookup_address_info): Likewise. Error check family argument. --- src/process.c | 84 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/process.c b/src/process.c index 2025398c22d..25f02afb297 100644 --- a/src/process.c +++ b/src/process.c @@ -276,6 +276,10 @@ static int read_process_output (Lisp_Object, int); static void create_pty (Lisp_Object); static void exec_sentinel (Lisp_Object, Lisp_Object); +static Lisp_Object +network_lookup_address_info_1 (Lisp_Object host, const char *service, + struct addrinfo *hints, struct addrinfo **res); + /* Number of bits set in connect_wait_mask. */ static int num_pending_connects; @@ -4064,7 +4068,7 @@ usage: (make-network-process &rest ARGS) */) if (!NILP (host)) { struct addrinfo *res, *lres; - int ret; + Lisp_Object msg; maybe_quit (); @@ -4073,20 +4077,11 @@ usage: (make-network-process &rest ARGS) */) hints.ai_family = family; hints.ai_socktype = socktype; - ret = getaddrinfo (SSDATA (host), portstring, &hints, &res); - if (ret) -#ifdef HAVE_GAI_STRERROR - { - synchronize_system_messages_locale (); - char const *str = gai_strerror (ret); - if (! NILP (Vlocale_coding_system)) - str = SSDATA (code_convert_string_norecord - (build_string (str), Vlocale_coding_system, 0)); - error ("%s/%s %s", SSDATA (host), portstring, str); - } -#else - error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); -#endif + msg = network_lookup_address_info_1 (host, portstring, &hints, &res); + if (!EQ(msg, Qt)) + { + error ("%s", SSDATA (msg)); + } for (lres = res; lres; lres = lres->ai_next) addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); @@ -4535,6 +4530,37 @@ Data that is unavailable is returned as nil. */) #endif } +static Lisp_Object +network_lookup_address_info_1 (Lisp_Object host, const char *service, + struct addrinfo *hints, struct addrinfo **res) +{ + Lisp_Object msg = Qt; + int ret; + + if (SBYTES (host) != SCHARS (host)) + error ("Non-ASCII hostname %s detected, please use puny-encode-domain", + SSDATA (host)); + ret = getaddrinfo (SSDATA (host), service, hints, res); + if (ret) + { + if (service == NULL) + service = "0"; +#ifdef HAVE_GAI_STRERROR + synchronize_system_messages_locale (); + char const *str = gai_strerror (ret); + if (! NILP (Vlocale_coding_system)) + str = SSDATA (code_convert_string_norecord + (build_string (str), Vlocale_coding_system, 0)); + AUTO_STRING (format, "%s/%s %s"); + msg = CALLN (Fformat, format, host, build_string (service), build_string (str)); +#else + AUTO_STRING (format, "%s/%s getaddrinfo error %d"); + msg = CALLN (Fformat, format, host, build_string (service), make_number (ret)); +#endif + } + return msg; +} + DEFUN ("network-lookup-address-info", Fnetwork_lookup_address_info, Snetwork_lookup_address_info, 1, 2, 0, doc: /* Look up ip address info of NAME. @@ -4545,42 +4571,32 @@ nil if none were found. Each address is a vector of integers. */) (Lisp_Object name, Lisp_Object family) { Lisp_Object addresses = Qnil; - struct addrinfo *res, *lres; - int ret; + Lisp_Object msg = Qnil; + struct addrinfo *res, *lres; struct addrinfo hints; - if (STRING_MULTIBYTE (name)) - error ("Non-ASCII hostname \"%s\" detected, please use puny-encode-string", - SSDATA (name)); memset (&hints, 0, sizeof hints); if (EQ (family, Qnil)) hints.ai_family = AF_UNSPEC; - if (EQ (family, Qipv4)) + else if (EQ (family, Qipv4)) hints.ai_family = AF_INET; - if (EQ (family, Qipv6)) + else if (EQ (family, Qipv6)) #ifdef AF_INET6 hints.ai_family = AF_INET6; #else /* If we don't support IPv6, querying will never work anyway */ return addresses; #endif + else + error ("Unsupported lookup type"); hints.ai_socktype = SOCK_DGRAM; - ret = getaddrinfo (SSDATA (name), NULL, &hints, &res); - if (ret) -#ifdef HAVE_GAI_STRERROR + msg = network_lookup_address_info_1 (name, NULL, &hints, &res); + if (!EQ(msg, Qt)) { - synchronize_system_messages_locale (); - char const *str = gai_strerror (ret); - if (! NILP (Vlocale_coding_system)) - str = SSDATA (code_convert_string_norecord - (build_string (str), Vlocale_coding_system, 0)); - message ("\"%s\" \"%s\"", SSDATA (name), str); + message ("%s", SSDATA(msg)); } -#else - message ("%s network-lookup-address-info error %d", SSDATA (name), ret); -#endif else { for (lres = res; lres; lres = lres->ai_next) -- cgit v1.2.1 From 742c2344bf076040f9c57f37b2220410f9e27304 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 17 Jul 2018 18:23:34 +0200 Subject: Don't check unibyte hostnames for pure-ASCII * src/process.c (network_lookup_address_info_1): Only check multibyte hostnames for pure-ASCII. * test/src/process-tests.el (unibyte-domain-name): Test unibyte domain names with network-lookup-address-info. --- src/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/process.c b/src/process.c index 25f02afb297..42909c4ba4f 100644 --- a/src/process.c +++ b/src/process.c @@ -4537,7 +4537,7 @@ network_lookup_address_info_1 (Lisp_Object host, const char *service, Lisp_Object msg = Qt; int ret; - if (SBYTES (host) != SCHARS (host)) + if (STRING_MULTIBYTE (host) && SBYTES (host) != SCHARS (host)) error ("Non-ASCII hostname %s detected, please use puny-encode-domain", SSDATA (host)); ret = getaddrinfo (SSDATA (host), service, hints, res); -- cgit v1.2.1 From 76662cc47d0dd1482442914d0b1f5011f0c86c5e Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Wed, 7 Aug 2019 13:55:38 +0200 Subject: fixup! Implement hostname->ip lookup function --- src/process.c | 40 ++++++++++++++++------------------------ src/process.h | 2 +- src/w32.c | 24 ++++++++---------------- 3 files changed, 25 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/process.c b/src/process.c index 42909c4ba4f..7b1723b9f56 100644 --- a/src/process.c +++ b/src/process.c @@ -2488,7 +2488,7 @@ usage: (make-pipe-process &rest ARGS) */) The address family of sa is not included in the result. */ Lisp_Object -conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len, bool include_port) +conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len) { Lisp_Object address; ptrdiff_t i; @@ -2507,12 +2507,9 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len, bool include_port) { DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa); len = sizeof (sin->sin_addr) + 1; - if (!include_port) - len--; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); - if (include_port) - p->contents[--len] = make_number (ntohs (sin->sin_port)); + p->contents[--len] = make_number (ntohs (sin->sin_port)); cp = (unsigned char *) &sin->sin_addr; break; } @@ -2522,12 +2519,9 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len, bool include_port) DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa); DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr); len = sizeof (sin6->sin6_addr) / 2 + 1; - if (!include_port) - len--; address = Fmake_vector (make_number (len), Qnil); p = XVECTOR (address); - if (include_port) - p->contents[--len] = make_number (ntohs (sin6->sin6_port)); + p->contents[--len] = make_number (ntohs (sin6->sin6_port)); for (i = 0; i < len; i++) p->contents[i] = make_number (ntohs (ip6[i])); return address; @@ -2578,7 +2572,7 @@ conv_addrinfo_to_lisp (struct addrinfo *res) { Lisp_Object protocol = make_number (res->ai_protocol); eassert (XINT (protocol) == res->ai_protocol); - return Fcons (protocol, conv_sockaddr_to_lisp (res->ai_addr, res->ai_addrlen, true)); + return Fcons (protocol, conv_sockaddr_to_lisp (res->ai_addr, res->ai_addrlen)); } @@ -2720,8 +2714,7 @@ set up yet, this function will block until socket setup has completed. */) channel = XPROCESS (process)->infd; return conv_sockaddr_to_lisp (datagram_address[channel].sa, - datagram_address[channel].len, - true); + datagram_address[channel].len); } DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_process_datagram_address, @@ -3582,7 +3575,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, #endif contact = Fplist_put (contact, p->is_server? QClocal: QCremote, - conv_sockaddr_to_lisp (sa, addrlen, true)); + conv_sockaddr_to_lisp (sa, addrlen)); #ifdef HAVE_GETSOCKNAME if (!p->is_server) { @@ -3591,7 +3584,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1); if (getsockname (s, psa1, &len1) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp (psa1, len1, true)); + conv_sockaddr_to_lisp (psa1, len1)); } #endif } @@ -4255,8 +4248,7 @@ network_interface_list (void) namebuf[sizeof (ifq->ifr_name)] = 0; res = Fcons (Fcons (build_string (namebuf), conv_sockaddr_to_lisp (&ifq->ifr_addr, - sizeof (struct sockaddr), - true)), + sizeof (struct sockaddr))), res); } @@ -4459,9 +4451,9 @@ network_interface_info (Lisp_Object ifname) { any = 1; #ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK - elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask), true); + elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask)); #else - elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr), true); + elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); #endif } #endif @@ -4472,7 +4464,7 @@ network_interface_info (Lisp_Object ifname) if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) { any = 1; - elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr), true); + elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr)); } #endif res = Fcons (elt, res); @@ -4482,7 +4474,7 @@ network_interface_info (Lisp_Object ifname) if (ioctl (s, SIOCGIFADDR, &rq) == 0) { any = 1; - elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr), true); + elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); } #endif res = Fcons (elt, res); @@ -4602,7 +4594,7 @@ nil if none were found. Each address is a vector of integers. */) for (lres = res; lres; lres = lres->ai_next) { addresses = Fcons (conv_sockaddr_to_lisp - (lres->ai_addr, lres->ai_addrlen, false), + (lres->ai_addr, lres->ai_addrlen), addresses); } addresses = Fnreverse (addresses); @@ -4879,12 +4871,12 @@ server_accept_connection (Lisp_Object server, int channel) if (!NILP (service)) contact = Fplist_put (contact, QCservice, service); contact = Fplist_put (contact, QCremote, - conv_sockaddr_to_lisp (&saddr.sa, len, true)); + conv_sockaddr_to_lisp (&saddr.sa, len)); #ifdef HAVE_GETSOCKNAME len = sizeof saddr; if (getsockname (s, &saddr.sa, &len) == 0) contact = Fplist_put (contact, QClocal, - conv_sockaddr_to_lisp (&saddr.sa, len, true)); + conv_sockaddr_to_lisp (&saddr.sa, len)); #endif pset_childp (p, contact); @@ -8116,7 +8108,7 @@ init_process_emacs (int sockfd) union u_sockaddr sa; socklen_t salen = sizeof sa; if (getsockname (sockfd, &sa.sa, &salen) == 0) - sockname = conv_sockaddr_to_lisp (&sa.sa, salen, true); + sockname = conv_sockaddr_to_lisp (&sa.sa, salen); } # endif Vinternal__daemon_sockname = sockname; diff --git a/src/process.h b/src/process.h index 504e5e6aaac..6bc22146a72 100644 --- a/src/process.h +++ b/src/process.h @@ -278,7 +278,7 @@ extern Lisp_Object system_process_attributes (Lisp_Object); extern void record_deleted_pid (pid_t, Lisp_Object); struct sockaddr; -extern Lisp_Object conv_sockaddr_to_lisp (struct sockaddr *, ptrdiff_t, bool); +extern Lisp_Object conv_sockaddr_to_lisp (struct sockaddr *, ptrdiff_t); extern void hold_keyboard_input (void); extern void unhold_keyboard_input (void); extern bool kbd_on_hold_p (void); diff --git a/src/w32.c b/src/w32.c index 4759b082eb5..c848b33b2af 100644 --- a/src/w32.c +++ b/src/w32.c @@ -9210,8 +9210,7 @@ network_interface_get_info (Lisp_Object ifname) if (NILP (ifname)) res = Fcons (Fcons (build_string (namebuf), conv_sockaddr_to_lisp ((struct sockaddr*) &sa, - sizeof (struct sockaddr), - false)), + sizeof (struct sockaddr))), res); else if (strcmp (namebuf, SSDATA (ifname)) == 0) { @@ -9258,8 +9257,7 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = net_mask; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); } else @@ -9276,16 +9274,14 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = bcast_addr; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); /* IP address. */ sa.sin_addr.s_addr = ip_addr; sa.sin_port = 0; res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); } else @@ -9303,8 +9299,7 @@ network_interface_get_info (Lisp_Object ifname) sa.sin_addr.s_addr = sys_inet_addr ("127.0.0.1"); res = Fcons (Fcons (build_string ("lo"), conv_sockaddr_to_lisp ((struct sockaddr*) &sa, - sizeof (struct sockaddr), - false)), + sizeof (struct sockaddr))), res); } else if (strcmp (SSDATA (ifname), "lo") == 0) @@ -9320,18 +9315,15 @@ network_interface_get_info (Lisp_Object ifname) res); sa.sin_addr.s_addr = sys_inet_addr ("255.0.0.0"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); sa.sin_addr.s_addr = sys_inet_addr ("0.0.0.0"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); sa.sin_addr.s_addr = sys_inet_addr ("127.0.0.1"); res = Fcons (conv_sockaddr_to_lisp ((struct sockaddr *) &sa, - sizeof (struct sockaddr), - false), + sizeof (struct sockaddr)), res); } -- cgit v1.2.1