aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/SSecurityRSAAES.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2024-12-17 11:02:19 +0100
committerPierre Ossman <ossman@cendio.se>2024-12-17 12:20:07 +0100
commit892832531627e16e61f6ccc602e1995cf065bba7 (patch)
tree9eac3ba8876850be3cb8ca0fbd579ba16234a4bf /common/rfb/SSecurityRSAAES.cxx
parent38ff2bdb913edafa26ebd9ba8ec3c94dc654d47c (diff)
downloadtigervnc-892832531627e16e61f6ccc602e1995cf065bba7.tar.gz
tigervnc-892832531627e16e61f6ccc602e1995cf065bba7.zip
Always flush sockets on shutdown()
The system shutdown() function doesn't drop buffered data, so neither should we. We had one fix in place, but that didn't cover all cases. Move this handling to all socket like classes we have.
Diffstat (limited to 'common/rfb/SSecurityRSAAES.cxx')
-rw-r--r--common/rfb/SSecurityRSAAES.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx
index 39b286de..fed213ad 100644
--- a/common/rfb/SSecurityRSAAES.cxx
+++ b/common/rfb/SSecurityRSAAES.cxx
@@ -74,6 +74,8 @@ BoolParameter SSecurityRSAAES::requireUsername
("RequireUsername", "Require username for the RSA-AES security types",
false, ConfServer);
+static LogWriter vlog("CSecurityRSAAES");
+
SSecurityRSAAES::SSecurityRSAAES(SConnection* sc_, uint32_t _secType,
int _keySize, bool _isAllEncrypted)
: SSecurity(sc_), state(SendPublicKey),
@@ -94,6 +96,19 @@ SSecurityRSAAES::~SSecurityRSAAES()
void SSecurityRSAAES::cleanup()
{
+ if (raos) {
+ try {
+ if (raos->hasBufferedData()) {
+ raos->cork(false);
+ raos->flush();
+ if (raos->hasBufferedData())
+ vlog.error("Failed to flush remaining socket data on close");
+ }
+ } catch (std::exception& e) {
+ vlog.error("Failed to flush remaining socket data on close: %s", e.what());
+ }
+ }
+
if (serverKeyN)
delete[] serverKeyN;
if (serverKeyE)