Skip to content

Commit

Permalink
use run-time version numbers (per dwmw)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
  • Loading branch information
dlenski committed Mar 30, 2020
1 parent 567d1ed commit 03dad77
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gnutls.c
Expand Up @@ -72,8 +72,8 @@ static char tls_library_version[32] = "";
const char *openconnect_get_tls_library_version()
{
if (!*tls_library_version) {
snprintf(tls_library_version, sizeof(tls_library_version), "GnuTLS v%d.%d.%d",
(GNUTLS_VERSION_NUMBER>>16), (GNUTLS_VERSION_NUMBER>>8)&0xff, GNUTLS_VERSION_NUMBER&0xff);
snprintf(tls_library_version, sizeof(tls_library_version), "GnuTLS %s",
gnutls_check_version(NULL));
}
return tls_library_version;
}
Expand Down
3 changes: 1 addition & 2 deletions library.c
Expand Up @@ -395,7 +395,6 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
if (vpninfo->ttls_bio_meth)
BIO_meth_free(vpninfo->ttls_bio_meth);
#endif
free(vpninfo->cstp_cipher);
#ifdef HAVE_DTLS
free(vpninfo->dtls_cipher_desc);
#endif
Expand Down Expand Up @@ -1028,7 +1027,7 @@ const char *openconnect_get_dtls_cipher(struct openconnect_info *vpninfo)
vpninfo->dtls_cipher_desc = get_gnutls_cipher(vpninfo->dtls_ssl);
#else
if (asprintf(&vpninfo->dtls_cipher_desc, "%s-%s",
SSL_get_version(dtls_ssl), SSL_get_cipher_name(dtls_ssl)) < 0)
SSL_get_version(vpninfo->dtls_ssl), SSL_get_cipher_name(vpninfo->dtls_ssl)) < 0)
return NULL;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion main.c
Expand Up @@ -593,7 +593,7 @@ static void print_build_opts(void)
{
const char *comma = ", ", *sep = comma + 1;

printf(_("Built with %s. Features present:"), openconnect_get_tls_library_version());
printf(_("Using %s. Features present:"), openconnect_get_tls_library_version());

if (openconnect_has_tss_blob_support()) {
printf("%sTPM", sep);
Expand Down
23 changes: 3 additions & 20 deletions openssl.c
Expand Up @@ -24,6 +24,7 @@

#include "openconnect-internal.h"

#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/engine.h>
Expand Down Expand Up @@ -53,27 +54,9 @@ static char tls_library_version[32] = "";

const char *openconnect_get_tls_library_version()
{
char patch[1] = "";
char status[10];
#ifdef OPENSSL_VERSION_NUMBER
const char *name = "OpenSSL";
const int vn = (int) OPENSSL_VERSION_NUMBER;
#elif defined(LIBRESSL_VERSION_NUMBER)
const char *name = "LibreSSL";
const int vn = (int) LIBRESSL_VERSION_NUMBER;
#endif

if (!*tls_library_version) {
/* https://www.openssl.org/docs/man1.1.0/man3/OPENSSL_VERSION_NUMBER.html */
patch[0] = ((vn>>4)&0xff) ? (((vn>>4)&0xff) + 'a' - 1) : 0;
switch (vn & 0xf) {
case 0: snprintf(status, sizeof(status), "dev"); break;
case 0xf: snprintf(status, sizeof(status), "release"); break;
default: snprintf(status, sizeof(status), "beta %d", vn & 0xf);
}
snprintf(tls_library_version, sizeof(tls_library_version), "%s v%d.%d.%d%.1s %s",
name, vn>>28, (vn>>20)&0xff, (vn>>12)&0xff,
patch, status);
strncpy(tls_library_version, SSLeay_version(SSLEAY_VERSION), sizeof(tls_library_version));
tls_library_version[sizeof(tls_library_version)-1]='\0';
}
return tls_library_version;
}
Expand Down

0 comments on commit 03dad77

Please sign in to comment.