]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3144] NTP does not build without openSSL
authorJuergen Perlinger <perlinger@ntp.org>
Tue, 22 Nov 2016 21:22:46 +0000 (22:22 +0100)
committerJuergen Perlinger <perlinger@ntp.org>
Tue, 22 Nov 2016 21:22:46 +0000 (22:22 +0100)
bk: 5834b726M5XQzLxCU01z1fMq6VRsyw

ChangeLog
include/ntp_md5.h
libntp/a_md5encrypt.c
libntp/libssl_compat.c
ntpd/ntp_control.c
ntpd/ntp_io.c
ports/winnt/ntpd/ntp_iocompletionport.c

index 0cb8c4fb4779b249944c144baf63c35be953e531..62b527bb6dd969a1fa03dd1e8abb3d04059df39d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
+---
+* [Bug 3144] NTP does not build without openSSL <perlinger@ntp.org>
+
 ---
 (4.2.8p9) 2016/11/21 Released by Harlan Stenn <stenn@ntp.org>
-(4.2.8p9) 2016/MM/DD Released by Harlan Stenn <stenn@ntp.org>
 
 * [Sec 3119] Trap crash <perlinger@ntp.org>
 * [Sec 3118] Mode 6 information disclosure and DDoS vector <perlinger@ntp.org>
index 2306b9a87fa6b9d9e68cc958e2cd511287b3c378..01b417a805169eb7d4912f772046aca82a41d487 100644 (file)
@@ -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)
index 7edcd2e305834a3995f42c499d3431b93b11347f..7394d0d27b357d59cd8b4fa36ff2f615ad69a23f 100644 (file)
@@ -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
  *
index ce6acb7d3c78374874b9d11bbee907d7fd976ac4..afe4d07a4b0a1c3d4c3c78f48e98595a7e07f092 100644 (file)
  * ---------------------------------------------------------------------
  */
 #include "config.h"
-
-#include <string.h>
-#include <openssl/bn.h>
-#include <openssl/evp.h>
-
 #include "ntp_types.h"
 
 /* ----------------------------------------------------------------- */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#ifdef OPENSSL
+# include <string.h>
+# include <openssl/bn.h>
+# include <openssl/evp.h>
+#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
index fac17a7adf27dba218abd46ef75341729c2f5524..7825b40d66cadf64ea60ba6d577c74d694b178f4 100644 (file)
@@ -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);
index 80642524ee2208a30feead42181b0b6250ac4c1c..1326be1fab6c5c4059dda4f04ff2ed15034143a5 100644 (file)
@@ -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,
index 251ba6a438ee8409baa9cf26b0f6cb5f81a71849..a52e7f86005dc962fe7915083063e750c5b91e04 100644 (file)
@@ -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);
 }
 
 /* --------------------------------------------------------------------