|
|
|
@ -221,10 +221,12 @@ TQ_LONG TDEKerberosClientSocket::readBlock(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
int wrlen;
|
|
|
|
|
char* buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize);
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
|
@ -273,10 +275,12 @@ TQ_LONG TDEKerberosClientSocket::readLine(char *data, TQ_ULONG maxlen) {
|
|
|
|
|
int wrlen;
|
|
|
|
|
char* buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize);
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
|
@ -313,10 +317,12 @@ TQString TDEKerberosClientSocket::readLine() {
|
|
|
|
|
int readlen;
|
|
|
|
|
char* buf = (char*)malloc(m_negotiatedMaxBufferSize);
|
|
|
|
|
reclen = receiveEncryptedData(buf, m_negotiatedMaxBufferSize);
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
if (reclen > 0) {
|
|
|
|
|
m_buffer->at(m_bufferLength);
|
|
|
|
|
wrlen = m_buffer->writeBlock(buf, reclen);
|
|
|
|
|
if (wrlen > 0) {
|
|
|
|
|
m_bufferLength = m_bufferLength + wrlen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
|
@ -447,13 +453,31 @@ int TDEKerberosClientSocket::transmitEncryptedData(int fd, const char* readbuf,
|
|
|
|
|
int result = 0;
|
|
|
|
|
unsigned int len;
|
|
|
|
|
const char *data;
|
|
|
|
|
|
|
|
|
|
result=sasl_encode(saslData->m_krbConnection, readbuf, cc, &data, &len);
|
|
|
|
|
if (result != SASL_OK) {
|
|
|
|
|
printf("[ERROR] Encrypting data returned %s (%d)\n\r", safe_sasl_errdetail(saslData->m_krbConnection), result);
|
|
|
|
|
return -1;
|
|
|
|
|
long data_remaining;
|
|
|
|
|
long remnant_position;
|
|
|
|
|
|
|
|
|
|
data_remaining = cc;
|
|
|
|
|
remnant_position = 0;
|
|
|
|
|
while (data_remaining > 0) {
|
|
|
|
|
int data_to_write_len;
|
|
|
|
|
if (data_remaining > (m_negotiatedMaxBufferSize/2)) {
|
|
|
|
|
data_to_write_len = m_negotiatedMaxBufferSize/2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
data_to_write_len = data_remaining;
|
|
|
|
|
}
|
|
|
|
|
result=sasl_encode(saslData->m_krbConnection, readbuf+remnant_position, data_to_write_len, &data, &len);
|
|
|
|
|
if (result != SASL_OK) {
|
|
|
|
|
printf("[ERROR] Encrypting data returned %s (%d)\n\r", safe_sasl_errdetail(saslData->m_krbConnection), result);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
sendSASLDataToNetwork(data, len, fd);
|
|
|
|
|
data_remaining = data_remaining - data_to_write_len;
|
|
|
|
|
remnant_position = remnant_position + data_to_write_len;
|
|
|
|
|
if (data_remaining > 0) {
|
|
|
|
|
tqApp->processEvents();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendSASLDataToNetwork(data, len, fd);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|