]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3430] ntpq dumps core (SIGSEGV) for "keytype md2"
authorJuergen Perlinger <perlinger@ntp.org>
Wed, 6 Sep 2017 11:10:55 +0000 (13:10 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Wed, 6 Sep 2017 11:10:55 +0000 (13:10 +0200)
 - fix MD5 fallback: only 'M' as keytype accepted
 - provide full digest list with MSVC for OpenSSL v1.0.1 and above

bk: 59afd7bf3IUWiot4M93rBZnT1lNnpg

libntp/ssl_init.c
ntpq/ntpq.c

index 4378263c0dec148f2e6840feef611ca25d9e17ac..a3c163b34e3772c9e71a4a39a3baa9ac2d2ca2fa 100644 (file)
@@ -118,7 +118,7 @@ keytype_from_text(
                *pch = (char)toupper((unsigned char)*pch);
 
        md = EVP_get_digestbyname(upcased);
-       if (NULL == md && 'M' == upcased[0])
+       if (NULL == md && !strcmp(upcased, "M"))
                md = EVP_get_digestbyname("MD5");
        if (NULL == md)
                return 0;
index f14a823cb412f8c006276aff837a7c34238bc65a..7c14b96524417946c91f5f67b31a07dd5e4ec82d 100644 (file)
@@ -3584,6 +3584,12 @@ ntpq_custom_opt_handler(
  * Obtain list of digest names
  */
 
+#if defined(OPENSSL) && !defined(HAVE_EVP_MD_DO_ALL_SORTED)
+# if defined(_MSC_VER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
+#  define HAVE_EVP_MD_DO_ALL_SORTED
+# endif
+#endif
+
 #ifdef OPENSSL
 # ifdef HAVE_EVP_MD_DO_ALL_SORTED
 struct hstate {