databases/freetds: Runtime fix with latest openssl

- FreeTDS fails to connect with MsSQL after the latest updates of
  OpenSSL specially after the release of 13.1 SNAPSHOTS including
  13.1-RELEASE and more specifically when openssl turned into 1.1.1l
  See the following for more details:
  https://github.com/FreeTDS/freetds/issues/458
- After the upgrade to version 1.3.9 FreeTDS fails to upgrade when using
  ports tree. [1]

PR:		261967 263641 [1]
Reported by:	jsc@ntu.edu.tw eugen [1]
This commit is contained in:
Muhammad Moinur Rahman 2022-05-31 01:14:13 -05:00
parent 89b8dcd9b0
commit 399af2d69e
2 changed files with 68 additions and 6 deletions

View file

@ -2,6 +2,7 @@
PORTNAME= freetds
PORTVERSION= 1.3.10
PORTREVISION= 1
PORTEPOCH= 1
CATEGORIES= databases
MASTER_SITES= https://www.freetds.org/files/stable/ \
@ -75,7 +76,8 @@ post-patch:
${WRKSRC}/Makefile.am
@${REINPLACE_CMD} -e 's|/pool.conf|/pool.conf.sample|g' \
${WRKSRC}/src/pool/Makefile.am
@${REINPLACE_CMD} -e 's|\($$with_iodbc/include\)|\1/libiodbc|g' \
@${REINPLACE_CMD} -e 's|\($$with_iodbc/include\)|\1/libiodbc|g ; \
s| odbcss.h||g' \
${WRKSRC}/configure.ac
post-install:

View file

@ -1,6 +1,6 @@
--- src/tds/tls.c.orig 2017-11-30 09:00:01 UTC
--- src/tds/tls.c.orig 2021-08-31 09:00:01 UTC
+++ src/tds/tls.c
@@ -50,6 +50,10 @@
@@ -53,6 +53,10 @@
#include <sys/socket.h>
#endif
@ -9,9 +9,18 @@
+#endif
+
#include <freetds/tds.h>
#include <freetds/string.h>
#include <freetds/utils/string.h>
#include <freetds/tls.h>
@@ -72,6 +76,15 @@
@@ -63,7 +67,7 @@
/**
* \addtogroup network
- * @{
+ * @{
*/
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
@@ -75,6 +79,15 @@
#define SSL_PTR ptr
#else
@ -25,5 +34,56 @@
+#endif
+
/* some compatibility layer */
#if OPENSSL_VERSION_NUMBER < 0x1010000FL
#if !HAVE_BIO_GET_DATA
static inline void
@@ -115,7 +128,7 @@ tds_pull_func_login(SSL_PULL_ARGS)
int have;
tdsdump_log(TDS_DBG_FUNC, "in tds_pull_func_login\n");
-
+
/* here we are initializing (crypted inside TDS packets) */
/* if we have some data send it */
@@ -450,7 +463,7 @@ tds_ssl_init(TDSSOCKET *tds)
const char *tls_msg;
xcred = NULL;
- session = NULL;
+ session = NULL;
tls_msg = "initializing tls";
if (!tls_initialized) {
@@ -826,18 +839,25 @@ check_name_match(ASN1_STRING *name, const char *hostna
static int
check_name_match(ASN1_STRING *name, const char *hostname)
{
- char *name_utf8 = NULL;
+ char *name_utf8 = NULL, *tmp_name;
int ret, name_len;
name_len = ASN1_STRING_to_UTF8((unsigned char **) &name_utf8, name);
if (name_len < 0)
return 0;
+ tmp_name = tds_strndup(name_utf8, name_len);
+ OPENSSL_free(name_utf8);
+ if (!tmp_name)
+ return 0;
+
+ name_utf8 = tmp_name;
+
tdsdump_log(TDS_DBG_INFO1, "Got name %s\n", name_utf8);
ret = 0;
if (strlen(name_utf8) == name_len && check_wildcard(name_utf8, hostname))
ret = 1;
- OPENSSL_free(name_utf8);
+ free(name_utf8);
return ret;
}
@@ -1095,4 +1115,3 @@ tds_ssl_deinit(TDSCONNECTION *conn)
#endif
/** @} */
-