diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-14 16:04:55 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-14 16:04:55 -0500 |
commit | 3b2621f9fea99c0c10b908941aaa919387b29fee (patch) | |
tree | 224e973b43dd938a6ce1f56c3b7a2241d9113b0e /lib/libtdekrb/src | |
parent | 8f56bf61ff4210b41226393d240fab14f01eee61 (diff) | |
download | ulab-3b2621f9fea99c0c10b908941aaa919387b29fee.tar.gz ulab-3b2621f9fea99c0c10b908941aaa919387b29fee.zip |
Fix a number of memory initialization glitches
Fix math waveform offset saving
Fix insane memory usage during SASL negotiation
Diffstat (limited to 'lib/libtdekrb/src')
-rw-r--r-- | lib/libtdekrb/src/tdekrbclientsocket.cpp | 39 | ||||
-rw-r--r-- | lib/libtdekrb/src/tdekrbserversocket.cpp | 29 |
2 files changed, 39 insertions, 29 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index 6179110..3663e7a 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -293,8 +293,9 @@ int TDEKerberosClientSocket::processPendingData() { while (TQSocket::canReadLine() && (TQSocket::state() == TQSocket::Connected)) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -353,8 +354,9 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) { int reclen; int wrlen; if (m_readBufferLength <= 0) { - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -434,8 +436,9 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) { int reclen; int wrlen; if (m_readBufferLength <= 0) { - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -486,8 +489,9 @@ TQString TDEKerberosClientSocket::readLine() { char* buf; maxlen = m_negotiatedMaxBufferSize; if (m_readBufferLength <= 0) { - buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return TQString::null; @@ -551,7 +555,8 @@ void TDEKerberosClientSocket::freeKerberosConnection(void) { void TDEKerberosClientSocket::sendSASLDataToNetwork(const char *buffer, unsigned length) { char *buf; - unsigned len, alloclen; + unsigned int len = 0; + unsigned int alloclen = 0; int result; alloclen = (((length / 3) + 1) * 4) + 1; @@ -567,7 +572,6 @@ void TDEKerberosClientSocket::sendSASLDataToNetwork(const char *buffer, unsigned return; } - len = strlen(buf); buf[len] = '\n'; buf[len+1] = 0; unsigned int ret = TQSocket::writeBlock(buf, len+1); @@ -689,9 +693,10 @@ int TDEKerberosClientSocket::receiveEncryptedData(char *buf, unsigned int truncl const char *recv_data; int result; int len; + int bytesAvailable = TQSocket::bytesAvailable(); - char *encbuf = (char*)malloc(m_negotiatedMaxBufferSize); - len = getSASLDataFromNetwork(encbuf, m_negotiatedMaxBufferSize, shouldblock); + char *encbuf = (char*)malloc(bytesAvailable); + len = getSASLDataFromNetwork(encbuf, bytesAvailable, shouldblock); if (len < 0) { return -1; } @@ -787,12 +792,12 @@ void TDEKerberosClientSocket::setStatusMessage(TQString message) { } void TDEKerberosClientSocket::continueKerberosInitialization() { - int slen; + int slen = 0; char buf[NET_SEC_BUF_SIZE]; - unsigned int len; - const char *data; - const char *chosenmech; - sasl_ssf_t *ssf; + unsigned int len = 0; + const char *data = 0; + const char *chosenmech = 0; + sasl_ssf_t *ssf = 0; if (m_krbInitRunning) { switch (m_krbInitState) { diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 89c645e..5a9f9ff 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -294,8 +294,9 @@ int TDEKerberosServerSocket::processPendingData() { while (TQSocket::canReadLine() && (TQSocket::state() == TQSocket::Connected)) { int reclen; int wrlen; - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -362,8 +363,9 @@ TQ_LONG TDEKerberosServerSocket::readBlock(char *data, TQ_ULONG maxlen) { int reclen; int wrlen; if (m_readBufferLength <= 0) { - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -443,8 +445,9 @@ TQ_LONG TDEKerberosServerSocket::readLine(char *data, TQ_ULONG maxlen) { int reclen; int wrlen; if (m_readBufferLength <= 0) { - char* buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + char* buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return -1; @@ -495,8 +498,9 @@ TQString TDEKerberosServerSocket::readLine() { char* buf; maxlen = m_negotiatedMaxBufferSize; if (m_readBufferLength <= 0) { - buf = (char*)malloc(m_negotiatedMaxBufferSize); - reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize, false); + int bytesAvailable = TQSocket::bytesAvailable(); + buf = (char*)malloc(bytesAvailable); + reclen = receiveEncryptedData(buf, bytesAvailable, false); if (reclen < 0) { free(buf); return TQString::null; @@ -560,7 +564,8 @@ void TDEKerberosServerSocket::freeKerberosConnection(void) { void TDEKerberosServerSocket::sendSASLDataToNetwork(const char *buffer, unsigned length) { char *buf; - unsigned len, alloclen; + unsigned int len = 0; + unsigned int alloclen = 0; int result; alloclen = (((length / 3) + 1) * 4) + 1; @@ -576,7 +581,6 @@ void TDEKerberosServerSocket::sendSASLDataToNetwork(const char *buffer, unsigned return; } - len = strlen(buf); buf[len] = '\n'; buf[len+1] = 0; unsigned int ret = TQSocket::writeBlock(buf, len+1); @@ -698,9 +702,10 @@ int TDEKerberosServerSocket::receiveEncryptedData(char *buf, unsigned int truncl const char *recv_data; int result; int len; + int bytesAvailable = TQSocket::bytesAvailable(); - char *encbuf = (char*)malloc(m_negotiatedMaxBufferSize); - len = getSASLDataFromNetwork(encbuf, m_negotiatedMaxBufferSize, shouldblock); + char *encbuf = (char*)malloc(bytesAvailable); + len = getSASLDataFromNetwork(encbuf, bytesAvailable, shouldblock); if (len < 0) { return -1; } |