Blame SOURCES/Implement-BIO_CTRL_GET_KTLS_SEND-and-BIO_CTRL_GET_KT.patch

c33cd6
From 1a0f68d2058f361fc23ed9babcd618a838744bf8 Mon Sep 17 00:00:00 2001
c33cd6
From: akarl <mike@mwsys.mine.bz>
c33cd6
Date: Sun, 24 Apr 2022 21:16:52 +0200
c33cd6
Subject: [PATCH] Implement BIO_CTRL_GET_KTLS_SEND and BIO_CTRL_GET_KTLS_SEND
c33cd6
c33cd6
Openssl 3.0 requires to respond to this controls. According to there
c33cd6
documentation it should not need them, but in practice openssl's own source
c33cd6
is full of places where negative return values are not checked.
c33cd6
c33cd6
(cherry picked from commit 9d7c20ce8fe50bd6de54e7480b5096761a510daf)
c33cd6
---
c33cd6
 libfreerdp/core/gateway/rdg.c | 18 +++++++++++++++++-
c33cd6
 libfreerdp/core/gateway/tsg.c |  9 ++++++++-
c33cd6
 2 files changed, 25 insertions(+), 2 deletions(-)
c33cd6
c33cd6
diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c
c33cd6
index 72019ede8..5d970f39e 100644
c33cd6
--- a/libfreerdp/core/gateway/rdg.c
c33cd6
+++ b/libfreerdp/core/gateway/rdg.c
c33cd6
@@ -2483,7 +2483,23 @@ static long rdg_bio_ctrl(BIO* in_bio, int cmd, long arg1, void* arg2)
c33cd6
 		 */
c33cd6
 		status = BIO_ctrl(tlsOut->bio, cmd, arg1, arg2);
c33cd6
 	}
c33cd6
-
c33cd6
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
c33cd6
+	else if (cmd == BIO_CTRL_GET_KTLS_SEND)
c33cd6
+	{
c33cd6
+		/* Even though BIO_get_ktls_send says that returning negative values is valid
c33cd6
+		 * openssl internal sources are full of if(!BIO_get_ktls_send && ) stuff. This has some
c33cd6
+		 * nasty sideeffects. return 0 as proper no KTLS offloading flag
c33cd6
+		 */
c33cd6
+		status = 0;
c33cd6
+	}
c33cd6
+	else if (cmd == BIO_CTRL_GET_KTLS_RECV)
c33cd6
+	{
c33cd6
+		/* Even though BIO_get_ktls_recv says that returning negative values is valid
c33cd6
+		 * there is no reason to trust  trust negative values are implemented right everywhere
c33cd6
+		 */
c33cd6
+		status = 0;
c33cd6
+	}
c33cd6
+#endif
c33cd6
 	return status;
c33cd6
 }
c33cd6
 
c33cd6
diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c
c33cd6
index c03f266f2..70fdf9e27 100644
c33cd6
--- a/libfreerdp/core/gateway/tsg.c
c33cd6
+++ b/libfreerdp/core/gateway/tsg.c
c33cd6
@@ -2716,7 +2716,14 @@ static long transport_bio_tsg_ctrl(BIO* bio, int cmd, long arg1, void* arg2)
c33cd6
 				status = 1;
c33cd6
 		}
c33cd6
 		break;
c33cd6
-
c33cd6
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
c33cd6
+		case BIO_CTRL_GET_KTLS_SEND:
c33cd6
+			status = 0;
c33cd6
+			break;
c33cd6
+		case BIO_CTRL_GET_KTLS_RECV:
c33cd6
+			status = 0;
c33cd6
+			break;
c33cd6
+#endif
c33cd6
 		default:
c33cd6
 			break;
c33cd6
 	}
c33cd6
-- 
c33cd6
2.36.1
c33cd6