diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 21:52:21 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-26 21:52:21 -0500 |
commit | 9c9085621bf01f9b39e15eb856ff521ecb01fccf (patch) | |
tree | 0d912f472a89ffccbcc3bb79ceed6a2b3a350118 /lib/libtdekrb/src | |
parent | b2f2dba837c0d28bf73ec36933af901f484633f5 (diff) | |
download | ulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.tar.gz ulab-9c9085621bf01f9b39e15eb856ff521ecb01fccf.zip |
Fix krb client/server sockets
Diffstat (limited to 'lib/libtdekrb/src')
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.cpp | 17 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 17 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index 647da73..96833a2 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -171,7 +171,7 @@ bool TDEKerberosClientSocket::atEnd() const { bool ret; if (m_kerberosRequested) { - return (m_buffer->at() >= (unsigned long)m_bufferLength); + ret = TQSocket::atEnd(); } else { ret = TQSocket::atEnd(); @@ -230,6 +230,9 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) { } free(buf); + if (maxlen > (unsigned int)m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); ret = m_buffer->readBlock(data, maxlen); if (ret > 0) { @@ -284,6 +287,9 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { } free(buf); + if (maxlen > (unsigned int)m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); ret = m_buffer->readLine(data, maxlen); if (ret > 0) { @@ -310,11 +316,13 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { TQString TDEKerberosClientSocket::readLine() { long i; TQString ret; + long maxlen; if (m_kerberosRequested) { int reclen; int wrlen; int readlen; + maxlen = m_negotiatedMaxBufferSize; char* buf = (char*)malloc(m_negotiatedMaxBufferSize); reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); if (reclen > 0) { @@ -326,9 +334,12 @@ TQString TDEKerberosClientSocket::readLine() { } free(buf); + if (maxlen > m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); - buf = (char*)malloc(m_negotiatedMaxBufferSize); - readlen = m_buffer->readLine(buf, m_negotiatedMaxBufferSize); + buf = (char*)malloc(maxlen); + readlen = m_buffer->readLine(buf, maxlen); if (readlen > 0) { // Remove the read bytes from the buffer m_bufferLength = m_bufferLength-readlen; diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 2b4d7d2..d99ddaa 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -171,7 +171,7 @@ bool TDEKerberosServerSocket::atEnd() const { bool ret; if (m_kerberosRequested) { - return (m_buffer->at() >= (unsigned long)m_bufferLength); + ret = TQSocket::atEnd(); } else { ret = TQSocket::atEnd(); @@ -230,6 +230,9 @@ TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) { } free(buf); + if (maxlen > (unsigned int)m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); ret = m_buffer->readBlock(data, maxlen); if (ret > 0) { @@ -284,6 +287,9 @@ TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { } free(buf); + if (maxlen > (unsigned int)m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); ret = m_buffer->readLine(data, maxlen); if (ret > 0) { @@ -310,11 +316,13 @@ TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { TQString TDEKerberosServerSocket::readLine() { long i; TQString ret; + long maxlen; if (m_kerberosRequested) { int reclen; int wrlen; int readlen; + maxlen = m_negotiatedMaxBufferSize; char* buf = (char*)malloc(m_negotiatedMaxBufferSize); reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize); if (reclen > 0) { @@ -326,9 +334,12 @@ TQString TDEKerberosServerSocket::readLine() { } free(buf); + if (maxlen > m_bufferLength) { + maxlen = m_bufferLength; + } m_buffer->at(0); - buf = (char*)malloc(m_negotiatedMaxBufferSize); - readlen = m_buffer->readLine(buf, m_negotiatedMaxBufferSize); + buf = (char*)malloc(maxlen); + readlen = m_buffer->readLine(buf, maxlen); if (readlen > 0) { // Remove the read bytes from the buffer m_bufferLength = m_bufferLength-readlen; |