From 9c9085621bf01f9b39e15eb856ff521ecb01fccf Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 26 Jun 2012 21:52:21 -0500 Subject: Fix krb client/server sockets --- lib/libtdekrb/src/tdekrbclientsocket.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/libtdekrb/src/tdekrbclientsocket.cpp') 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; -- cgit v1.2.1