From 3b2621f9fea99c0c10b908941aaa919387b29fee Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 14 Sep 2014 16:04:55 -0500 Subject: [PATCH] Fix a number of memory initialization glitches Fix math waveform offset saving Fix insane memory usage during SASL negotiation --- clients/tde/src/part/scope/part.cpp | 105 +++++++++++----------- clients/tde/src/part/scope/part.h | 2 +- clients/tde/src/widgets/tracewidget.cpp | 10 ++- lib/libtdekrb/src/tdekrbclientsocket.cpp | 39 ++++---- lib/libtdekrb/src/tdekrbserversocket.cpp | 29 +++--- servers/gpib_server_lin/src/gpib_conn.cpp | 2 - 6 files changed, 101 insertions(+), 86 deletions(-) diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp index cb38e07..274480a 100644 --- a/clients/tde/src/part/scope/part.cpp +++ b/clients/tde/src/part/scope/part.cpp @@ -455,7 +455,7 @@ void TimebaseControlWidget::sdivChanged(int index) { ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList& ) : RemoteInstrumentPart( parent, name ), m_traceWidget(0), m_commHandlerState(-1), m_commHandlerMode(0), m_commHandlerCommandState(0), m_connectionActiveAndValid(false), - m_triggerChannel(-1), m_settingsChanged(false), m_base(0), stopTraceUpdate(false) + m_tickerState(0), m_triggerChannel(-1), m_running(false), m_triggerLevel(0), m_settingsChanged(false), m_base(0), m_stopTraceUpdate(false) { // Initialize important base class variables m_clientLibraryName = CLIENT_LIBRARY; @@ -619,7 +619,7 @@ void ScopePart::processLockouts() { } // Middle area - if (((m_commHandlerMode < 2) && (m_commHandlerState < 50)) || (stopTraceUpdate)) { + if (((m_commHandlerMode < 2) && (m_commHandlerState < 50)) || (m_stopTraceUpdate)) { m_base->groupOscilloscopeCaptureControls->setEnabled(false); } else { @@ -627,7 +627,7 @@ void ScopePart::processLockouts() { } // Least area - if (stopTraceUpdate) { + if (m_stopTraceUpdate) { m_base->acqStop->setEnabled(false); m_base->acqStart->setEnabled(true); m_base->waveformSave->setEnabled(true); @@ -793,7 +793,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -803,7 +803,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -836,7 +836,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -846,7 +846,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -882,7 +882,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -892,7 +892,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -928,7 +928,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -938,7 +938,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -950,7 +950,6 @@ void ScopePart::mainEventLoop() { else if (m_commHandlerState == ScopeState_PermittedSecondsDivRequest) { // Get permitted seconds/div settings, step 1 ds << TQString("GETPERMITTEDSDIVS"); - ds << m_currentOpChannel; m_socket->writeEndOfFrame(); SET_NEXT_STATE_DATA_WAITING(ScopeState_PermittedSecondsDivRequest+1) @@ -977,7 +976,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -987,7 +986,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1028,7 +1027,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1038,7 +1037,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1090,7 +1089,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1100,7 +1099,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1144,7 +1143,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1154,7 +1153,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1201,7 +1200,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1211,7 +1210,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1255,7 +1254,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1265,7 +1264,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1308,7 +1307,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1318,7 +1317,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1356,7 +1355,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1366,7 +1365,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1403,7 +1402,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1413,7 +1412,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1455,7 +1454,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1465,7 +1464,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1510,7 +1509,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1520,7 +1519,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1594,7 +1593,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1604,7 +1603,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1667,7 +1666,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1677,7 +1676,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1731,7 +1730,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1741,7 +1740,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1782,7 +1781,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1792,7 +1791,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1833,7 +1832,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1843,7 +1842,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1884,7 +1883,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1894,7 +1893,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -1951,7 +1950,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -1961,7 +1960,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -2010,7 +2009,7 @@ void ScopePart::mainEventLoop() { EXEC_NEXT_STATE_IMMEDIATELY } else { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { COMMUNICATIONS_FAILED } else { @@ -2020,7 +2019,7 @@ void ScopePart::mainEventLoop() { } else { if (!m_updateTimeoutTimer->isActive()) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { UPDATEDISPLAY_TIMEOUT } else { @@ -2030,7 +2029,7 @@ void ScopePart::mainEventLoop() { } } else if (m_commHandlerCommandState == 3) { - if (stopTraceUpdate == false) { + if (m_stopTraceUpdate == false) { m_commHandlerCommandState = 0; EXEC_NEXT_STATE_IMMEDIATELY } @@ -2055,14 +2054,14 @@ void ScopePart::postProcessTrace() { } void ScopePart::startDAQ() { - stopTraceUpdate = false; + m_stopTraceUpdate = false; if (m_socket) m_socket->clearIncomingData(); EXEC_NEXT_STATE_IMMEDIATELY } void ScopePart::stopDAQ() { if (m_commHandlerMode < 2) { - stopTraceUpdate = true; + m_stopTraceUpdate = true; for (int i=0; i<=MAXTRACES;i++) { m_channelActiveSet[i] = false; m_voltsDivSet[i] = false; diff --git a/clients/tde/src/part/scope/part.h b/clients/tde/src/part/scope/part.h index 18d2e75..f483a6b 100644 --- a/clients/tde/src/part/scope/part.h +++ b/clients/tde/src/part/scope/part.h @@ -266,7 +266,7 @@ namespace RemoteLab MathOperatorList m_availableMathOperators; ScopeBase* m_base; TQMutex* m_instrumentMutex; - bool stopTraceUpdate; + bool m_stopTraceUpdate; }; } diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp index 8ceba00..5aec418 100644 --- a/clients/tde/src/widgets/tracewidget.cpp +++ b/clients/tde/src/widgets/tracewidget.cpp @@ -49,6 +49,10 @@ #define CURSOR_MOVE_CAPTURE_DISTANCE 0 TQRectF::TQRectF() { + m_x = 0; + m_y = 0; + m_w = 0; + m_h = 0; m_valid = false; } @@ -537,6 +541,9 @@ TQSize TraceCursorLabelLayout::minimumSize() const TraceData::TraceData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) { color = TQColor(0, 255, 0); numberOfSamples = 0; + sampleMax = 0; + sampleMin = 0; + sampleAverage = 0; leftEdgeIndex = -1; rightEdgeIndex = -1; offset = 0.0; @@ -812,7 +819,7 @@ void TraceData::setVPosition() { double newoffset; ok = false; - newoffset = KInputDialog::getDouble(i18n("Set Trace Offset"), i18n("New offset for %1 (%2):").arg(traceName).arg(verticalUnits), offset, (double)-2147483647, (double)2147483647, 0.1, 1, &ok, parentWidget); + newoffset = KInputDialog::getDouble(i18n("Set Trace Offset"), i18n("New offset for %1 (%2):").arg(traceName).arg(verticalUnits), offset, double(INT_MIN), double(INT_MAX), 0.1, 1, &ok, parentWidget); if (ok) { offset = newoffset; emit(offsetChanged(offset)); @@ -1825,6 +1832,7 @@ void TraceWidget::setSamples(uint traceNumber, TQDoubleArray& tqda, bool deferUp m_traceArray[traceNumber]->sampleAverage = m_traceArray[traceNumber]->sampleAverage / m_traceArray[traceNumber]->numberOfSamples; if (!deferUpdate) { + updateTraceText(); updateCursorText(); m_graticuleWidget->repaint(false); } 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; } diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp index 74d787e..ec36aa6 100644 --- a/servers/gpib_server_lin/src/gpib_conn.cpp +++ b/servers/gpib_server_lin/src/gpib_conn.cpp @@ -564,8 +564,6 @@ void GPIBSocket::commandLoop() { else if (m_instrumentCommand == "GETPERMITTEDSDIVS") { // Want to get permitted seconds/div settings double* permitted_array; int permitted_count; - TQ_INT32 value; - ds >> value; if (scope_get_permitted_seconds_div_settings(&permitted_count, &permitted_array, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) { long i; TQDoubleList permittedValues;