diff options
author | gbdj <gbdj@users.noreply.github.com> | 2016-04-23 14:42:49 +0400 |
---|---|---|
committer | gbdj <gbdj@users.noreply.github.com> | 2016-04-23 14:42:49 +0400 |
commit | 1da7872784a78446284b4e8ef71691458296026c (patch) | |
tree | 706695146857b769b4cf8eaa17451b30b72284d1 /libvncclient/tls_gnutls.c | |
parent | 5b322f523faa437d8e7d03736bdb1714e8f84ce5 (diff) | |
download | libtdevnc-1da7872784a78446284b4e8ef71691458296026c.tar.gz libtdevnc-1da7872784a78446284b4e8ef71691458296026c.zip |
libvncclient/tls_gnutls.c: Add hooks to WriteToTLS() for optional protection by mutex. Fix upstream issue #100
Squashed commit of the pull request #101 :
commit 1c7e01e81862bc46508e675e83c74cc6d63224b0
commit 1e749b094d6696380d3f0540a00138d7e3427874
Diffstat (limited to 'libvncclient/tls_gnutls.c')
-rw-r--r-- | libvncclient/tls_gnutls.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libvncclient/tls_gnutls.c b/libvncclient/tls_gnutls.c index 3daa416..91cea67 100644 --- a/libvncclient/tls_gnutls.c +++ b/libvncclient/tls_gnutls.c @@ -480,6 +480,14 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n) unsigned int offset = 0; ssize_t ret; + if (client->LockWriteToTLS) + { + if (!client->LockWriteToTLS(client)) + { + rfbClientLog("Callback to get lock in WriteToTLS() failed\n"); + return -1; + } + } while (offset < n) { ret = gnutls_record_send((gnutls_session_t)client->tlsSession, buf+offset, (size_t)(n-offset)); @@ -488,10 +496,23 @@ WriteToTLS(rfbClient* client, char *buf, unsigned int n) { if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED) continue; rfbClientLog("Error writing to TLS: %s.\n", gnutls_strerror(ret)); + if (client->UnlockWriteToTLS) + { + if (!client->UnlockWriteToTLS(client)) + rfbClientLog("Callback to unlock WriteToTLS() failed\n"); + } return -1; } offset += (unsigned int)ret; } + if (client->UnlockWriteToTLS) + { + if (!client->UnlockWriteToTLS(client)) + { + rfbClientLog("Callback to unlock WriteToTLS() failed\n"); + return -1; + } + } return offset; } |