summaryrefslogtreecommitdiffstats
path: root/lib/libtdekrb/src/tdekrbclientsocket.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-22 15:02:32 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-22 15:02:32 -0500
commitb48b26b86975d2166a4da7fc41086facefb3c4f2 (patch)
tree149c0a635434e9c46febf272cae6fde90a4a65ef /lib/libtdekrb/src/tdekrbclientsocket.cpp
parentb1ee542e95f9358985970d141701d766ac30cea2 (diff)
downloadulab-b48b26b86975d2166a4da7fc41086facefb3c4f2.tar.gz
ulab-b48b26b86975d2166a4da7fc41086facefb3c4f2.zip
Fix problems with Kerberos sockets
Diffstat (limited to 'lib/libtdekrb/src/tdekrbclientsocket.cpp')
-rw-r--r--lib/libtdekrb/src/tdekrbclientsocket.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp
index c9db10a..053dd23 100644
--- a/lib/libtdekrb/src/tdekrbclientsocket.cpp
+++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp
@@ -115,8 +115,8 @@ void TDEKerberosClientSocket::setServerFQDN(TQString name) {
m_serverFQDN = name;
}
-Q_LONG TDEKerberosClientSocket::readBlock(char *data, Q_ULONG maxlen) {
- Q_LONG ret;
+TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) {
+ TQ_LONG ret;
if (m_kerberosRequested) {
ret = receiveEncryptedData(data, maxlen);
@@ -128,8 +128,8 @@ Q_LONG TDEKerberosClientSocket::readBlock(char *data, Q_ULONG maxlen) {
return ret;
}
-Q_LONG TDEKerberosClientSocket::writeBlock(const char *data, Q_ULONG len) {
- Q_LONG ret;
+TQ_LONG TDEKerberosClientSocket::writeBlock(const char *data, TQ_ULONG len) {
+ TQ_LONG ret;
if (m_kerberosRequested) {
ret = transmitEncryptedData(socket(), data, len);
@@ -141,11 +141,11 @@ Q_LONG TDEKerberosClientSocket::writeBlock(const char *data, Q_ULONG len) {
return ret;
}
-Q_LONG TDEKerberosClientSocket::readLine(char *data, Q_ULONG maxlen) {
- Q_LONG ret;
+TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) {
+ TQ_LONG ret;
if (m_kerberosRequested) {
- ret = getSASLDataFromNetwork(data, maxlen);
+ ret = receiveEncryptedData(data, maxlen);
}
else {
ret = TQSocket::readLine(data, maxlen);
@@ -236,7 +236,6 @@ unsigned int TDEKerberosClientSocket::getSASLDataFromNetwork(char *buf, int trun
}
if (len >= (ba.size()-1)) {
ba.resize(ba.size()+2048);
- break;
}
}
@@ -272,16 +271,22 @@ int TDEKerberosClientSocket::receiveEncryptedData(char *buf, int trunclen) {
int result;
int len;
- len = getSASLDataFromNetwork(buf, trunclen);
+ char *encbuf = (char*)malloc(m_negotiatedMaxBufferSize);
+ len = getSASLDataFromNetwork(encbuf, m_negotiatedMaxBufferSize);
if (len >= 0) {
- result=sasl_decode(saslData->m_krbConnection, buf, len, &recv_data, &recv_len);
+ result=sasl_decode(saslData->m_krbConnection, encbuf, len, &recv_data, &recv_len);
if (result != SASL_OK) {
+ free(encbuf);
printf("[ERROR] Decrypting data returned %s (%d)\n\r", sasl_errdetail(saslData->m_krbConnection), result);
return -1;
}
- strncpy(buf, recv_data, trunclen);
+ if (recv_len > trunclen) {
+ recv_len = trunclen;
+ }
+ memcpy(buf, recv_data, recv_len);
}
+ free(encbuf);
return 0;
}