summaryrefslogtreecommitdiffstats
path: root/lib/libtdekrb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libtdekrb')
-rw-r--r--lib/libtdekrb/src/tdekrbclientsocket.cpp39
-rw-r--r--lib/libtdekrb/src/tdekrbserversocket.cpp29
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;
}