From: Juergen Perlinger Date: Wed, 6 Sep 2017 11:10:55 +0000 (+0200) Subject: [Bug 3430] ntpq dumps core (SIGSEGV) for "keytype md2" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c23be289e6fc3015f9bc9f70b8b145af3cc2358;p=thirdparty%2Fntp.git [Bug 3430] ntpq dumps core (SIGSEGV) for "keytype md2" - fix MD5 fallback: only 'M' as keytype accepted - provide full digest list with MSVC for OpenSSL v1.0.1 and above bk: 59afd7bf3IUWiot4M93rBZnT1lNnpg --- diff --git a/libntp/ssl_init.c b/libntp/ssl_init.c index 4378263c0..a3c163b34 100644 --- a/libntp/ssl_init.c +++ b/libntp/ssl_init.c @@ -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; diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index f14a823cb..7c14b9652 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -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 {