diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-22 15:02:32 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-22 15:02:32 -0500 |
commit | b48b26b86975d2166a4da7fc41086facefb3c4f2 (patch) | |
tree | 149c0a635434e9c46febf272cae6fde90a4a65ef /lib/libtdekrb/src/tdekrbserversocket.cpp | |
parent | b1ee542e95f9358985970d141701d766ac30cea2 (diff) | |
download | ulab-b48b26b86975d2166a4da7fc41086facefb3c4f2.tar.gz ulab-b48b26b86975d2166a4da7fc41086facefb3c4f2.zip |
Fix problems with Kerberos sockets
Diffstat (limited to 'lib/libtdekrb/src/tdekrbserversocket.cpp')
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 0704aeb..1d7cfbf 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -115,8 +115,8 @@ void TDEKerberosServerSocket::setServerFQDN(TQString name) { m_serverFQDN = name; } -Q_LONG TDEKerberosServerSocket::readBlock(char *data, Q_ULONG maxlen) { - Q_LONG ret; +TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) { + TQ_LONG ret; if (m_kerberosRequested) { ret = receiveEncryptedData(data, maxlen); @@ -128,8 +128,8 @@ Q_LONG TDEKerberosServerSocket::readBlock(char *data, Q_ULONG maxlen) { return ret; } -Q_LONG TDEKerberosServerSocket::writeBlock(const char *data, Q_ULONG len) { - Q_LONG ret; +TQ_LONG TDEKerberosServerSocket::writeBlock(const char *data, TQ_ULONG len) { + TQ_LONG ret; if (m_kerberosRequested) { ret = transmitEncryptedData(socket(), data, len); @@ -141,11 +141,11 @@ Q_LONG TDEKerberosServerSocket::writeBlock(const char *data, Q_ULONG len) { return ret; } -Q_LONG TDEKerberosServerSocket::readLine(char *data, Q_ULONG maxlen) { - Q_LONG ret; +TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { + TQ_LONG ret; if (m_kerberosRequested) { - ret = getSASLDataFromNetwork(data, maxlen); + ret = receiveEncryptedData(data, maxlen); } else { ret = TQSocket::readLine(data, maxlen); @@ -236,7 +236,6 @@ unsigned int TDEKerberosServerSocket::getSASLDataFromNetwork(char *buf, int trun } if (len >= (ba.size()-1)) { ba.resize(ba.size()+2048); - break; } } @@ -272,16 +271,22 @@ int TDEKerberosServerSocket::receiveEncryptedData(char *buf, int trunclen) { int result; int len; - len = getSASLDataFromNetwork(buf, trunclen); + char *encbuf = (char*)malloc(m_negotiatedMaxBufferSize); + len = getSASLDataFromNetwork(encbuf, m_negotiatedMaxBufferSize); if (len >= 0) { - result=sasl_decode(saslData->m_krbConnection, buf, len, &recv_data, &recv_len); + result=sasl_decode(saslData->m_krbConnection, encbuf, len, &recv_data, &recv_len); if (result != SASL_OK) { + free(encbuf); printf("[ERROR] Decrypting data returned %s (%d)\n\r", sasl_errdetail(saslData->m_krbConnection), result); return -1; } - strncpy(buf, recv_data, trunclen); + if (recv_len > trunclen) { + recv_len = trunclen; + } + memcpy(buf, recv_data, recv_len); } + free(encbuf); return 0; } |