From: Juergen Perlinger Date: Tue, 22 Nov 2016 21:22:46 +0000 (+0100) Subject: [Bug 3144] NTP does not build without openSSL X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca9b590b1b1cce499716bf3e6c6fd71676c8a6b;p=thirdparty%2Fntp.git [Bug 3144] NTP does not build without openSSL bk: 5834b726M5XQzLxCU01z1fMq6VRsyw --- diff --git a/ChangeLog b/ChangeLog index 0cb8c4fb4..62b527bb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ +--- +* [Bug 3144] NTP does not build without openSSL + --- (4.2.8p9) 2016/11/21 Released by Harlan Stenn -(4.2.8p9) 2016/MM/DD Released by Harlan Stenn * [Sec 3119] Trap crash * [Sec 3118] Mode 6 information disclosure and DDoS vector diff --git a/include/ntp_md5.h b/include/ntp_md5.h index 2306b9a87..01b417a80 100644 --- a/include/ntp_md5.h +++ b/include/ntp_md5.h @@ -8,6 +8,7 @@ #ifdef OPENSSL # include "openssl/evp.h" +# include "libssl_compat.h" #else /* !OPENSSL follows */ /* * Provide OpenSSL-alike MD5 API if we're not using OpenSSL @@ -23,6 +24,9 @@ # endif typedef MD5_CTX EVP_MD_CTX; + +# define EVP_MD_CTX_free(c) free(c) +# define EVP_MD_CTX_new() calloc(1, sizeof(MD5_CTX)) # define EVP_get_digestbynid(t) NULL # define EVP_md5() NULL # define EVP_MD_CTX_init(c) diff --git a/libntp/a_md5encrypt.c b/libntp/a_md5encrypt.c index 7edcd2e30..7394d0d27 100644 --- a/libntp/a_md5encrypt.c +++ b/libntp/a_md5encrypt.c @@ -11,7 +11,6 @@ #include "ntp.h" #include "ntp_md5.h" /* provides OpenSSL digest API */ #include "isc/string.h" -#include "libssl_compat.h" /* * MD5authencrypt - generate message digest * diff --git a/libntp/libssl_compat.c b/libntp/libssl_compat.c index ce6acb7d3..afe4d07a4 100644 --- a/libntp/libssl_compat.c +++ b/libntp/libssl_compat.c @@ -15,15 +15,18 @@ * --------------------------------------------------------------------- */ #include "config.h" - -#include -#include -#include - #include "ntp_types.h" /* ----------------------------------------------------------------- */ -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#ifdef OPENSSL +# include +# include +# include +#endif +/* ----------------------------------------------------------------- */ + +/* ----------------------------------------------------------------- */ +#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER < 0x10100000L /* ----------------------------------------------------------------- */ #include "libssl_compat.h" @@ -325,7 +328,7 @@ sslshim_X509_get_signature_nid( } /* ----------------------------------------------------------------- */ -#else /* OPENSSL_VERSION_NUMBER >= v1.1.0 */ +#else /* OPENSSL && OPENSSL_VERSION_NUMBER >= v1.1.0 */ /* ----------------------------------------------------------------- */ NONEMPTY_TRANSLATION_UNIT diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index fac17a7ad..7825b40d6 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -33,8 +33,6 @@ # include "ntp_syscall.h" #endif -#include "libssl_compat.h" - /* * Structure to hold request procedure information */ @@ -1838,7 +1836,7 @@ ctl_putrefid( char * oplim; char * iptr; char * iplim; - char * past_eq; + char * past_eq = NULL; optr = output; oplim = output + sizeof(output); diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 80642524e..1326be1fa 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -516,13 +516,17 @@ io_open_sockets(void) /* * function to dump the contents of the interface structure * for debugging use only. + * We face a dilemma here -- sockets are FDs under POSIX and + * actually HANDLES under Windows. So we use '%lld' as format + * and cast the value to 'long long'; this should not hurt + * with UNIX-like systems and does not truncate values on Win64. */ void interface_dump(const endpt *itf) { printf("Dumping interface: %p\n", itf); - printf("fd = %d\n", itf->fd); - printf("bfd = %d\n", itf->bfd); + printf("fd = %lld\n", (long long)itf->fd); + printf("bfd = %lld\n", (long long)itf->bfd); printf("sin = %s,\n", stoa(&itf->sin)); sockaddr_dump(&itf->sin); printf("bcast = %s,\n", stoa(&itf->bcast)); @@ -570,11 +574,11 @@ sockaddr_dump(const sockaddr_u *psau) static void print_interface(const endpt *iface, const char *pfx, const char *sfx) { - printf("%sinterface #%d: fd=%d, bfd=%d, name=%s, flags=0x%x, ifindex=%u, sin=%s", + printf("%sinterface #%d: fd=%lld, bfd=%lld, name=%s, flags=0x%x, ifindex=%u, sin=%s", pfx, iface->ifnum, - iface->fd, - iface->bfd, + (long long)iface->fd, + (long long)iface->bfd, iface->name, iface->flags, iface->ifindex, diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c index 251ba6a43..a52e7f860 100644 --- a/ports/winnt/ntpd/ntp_iocompletionport.c +++ b/ports/winnt/ntpd/ntp_iocompletionport.c @@ -1391,8 +1391,7 @@ io_completion_port_add_clock_io( goto fail; } - ; - if ( ! (rio->ioreg_ctx = iopad = iohpCreate(rio))) { + if (NULL == (rio->ioreg_ctx = iopad = iohpCreate(rio))) { msyslog(LOG_ERR, "%s: Failed to create shared lock", msgh); goto fail; @@ -1401,13 +1400,13 @@ io_completion_port_add_clock_io( iopad->riofd = rio->fd; iopad->rsrc.rio = rio; - if (!(rio->device_ctx = DevCtxAttach(serial_devctx(h)))) { + if (NULL == (rio->device_ctx = DevCtxAttach(serial_devctx(h)))) { msyslog(LOG_ERR, "%s: Failed to allocate device context", msgh); goto fail; } - if ( ! (lpo = IoCtxAlloc(iopad, rio->device_ctx))) { + if (NULL == (lpo = IoCtxAlloc(iopad, rio->device_ctx))) { msyslog(LOG_ERR, "%: Failed to allocate IO context", msgh); goto fail; @@ -1594,7 +1593,6 @@ OnSocketSend( static const char * const msg = "OnSocketSend: send to socket failed"; - IoHndPad_T * iopad = NULL; endpt * ep = NULL; int rc; @@ -1662,7 +1660,7 @@ io_completion_port_remove_interface( INSIST(hndIOCPLPort && hMainRpcDone); if (iopad) - iocpl_notify(iopad, OnInterfaceDetach, -1); + iocpl_notify(iopad, OnInterfaceDetach, (UINT_PTR)-1); } /* --------------------------------------------------------------------