void SendPacket();
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
CFile* OpenFile(bool bWrite = true);
- bool Seek(unsigned int uPos);
+ bool Seek(unsigned long int uPos);
// Setters
void SetRemoteIP(const CString& s) { m_sRemoteIP = s; }
CString m_sLocalFile;
CString m_sSendBuf;
unsigned short m_uRemotePort;
- unsigned long m_uFileSize;
- unsigned long m_uBytesSoFar;
+ unsigned long long m_uFileSize;
+ unsigned long long m_uBytesSoFar;
bool m_bSend;
bool m_bNoDelFile;
CFile* m_pFile;
} else {
m_pFile->Write(data, len);
m_uBytesSoFar += len;
- uint32_t uSoFar = htonl(m_uBytesSoFar);
+ uint32_t uSoFar = htonl((uint32_t)m_uBytesSoFar);
Write((char*) &uSoFar, sizeof(uSoFar));
if (m_uBytesSoFar >= m_uFileSize) {
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
- if (uFileSize > (unsigned long long) 0xffffffff) {
+ if (uFileSize > (unsigned long long) 0xffffffffULL) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - File too large (>4 GiB) [" + m_sLocalFile + "]");
return NULL;
}
- m_uFileSize = (unsigned long) uFileSize;
+ m_uFileSize = uFileSize;
}
m_sFileName = m_pFile->GetShortName();
return m_pFile;
}
-bool CDCCSock::Seek(unsigned int uPos) {
+bool CDCCSock::Seek(unsigned long int uPos) {
if (m_pFile) {
if (m_pFile->Seek(uPos)) {
m_uBytesSoFar = uPos;
CString sOuterKey, sInnerKey;
CString::size_type iKeyLength = sRealKey.length();
for (unsigned int i = 0; i < 64; i++) {
- int r = (i < iKeyLength ? sRealKey[i] : 0);
+ char r = (i < iKeyLength ? sRealKey[i] : '\0');
sOuterKey += r ^ 0x5c;
sInnerKey += r ^ 0x36;
}
}
/* Prime number */
- unsigned int size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
- size = ntohs(*(unsigned int*)data);
+ unsigned int size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
return false;
}
- size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
- size = ntohs(*(unsigned int*)data);
+ size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
data += size;
/* Server public key */
- size = ntohs((((unsigned int)data[1]) << 8) | data[0]);
- size = ntohs(*(unsigned int*)data);
+ size = ntohs(*(uint16_t*)data);
data += 2;
length -= 2;
}
/* Encrypt our sasl password with blowfish */
+ // TODO for passwords with length 8, 16, 24, 32, etc. this will have 8 additional zero bytes at the end... But it works when treated as null-terminated string anyway, and if it works I don't want to touch it right now.
CString::size_type password_length = GetNV("password").size() + (8 - (GetNV("password").size() % 8));
unsigned char *encrypted_password = (unsigned char *)malloc(password_length);
char *plaintext_password = (char *)malloc(password_length);
out_ptr = response;
/* Add our key to the response */
- *((unsigned int *)out_ptr) = htons(BN_num_bytes(dh->pub_key));
+ *((uint16_t *)out_ptr) = htons((uint16_t)BN_num_bytes(dh->pub_key));
out_ptr += 2;
BN_bn2bin(dh->pub_key, (unsigned char *)out_ptr);
out_ptr += BN_num_bytes(dh->pub_key);
}
ssize_t res = write(m_iFD, pszBuffer, iBytes);
- if (res != iBytes)
+ if (-1 == res)
m_bHadError = true;
return res;
}
// This is in [0:1e6], which means that roughly 20 bits are
// actually used, let's try to shuffle the high bits.
- seed ^= (tv.tv_usec << 10) | tv.tv_usec;
+ seed ^= uint32_t((tv.tv_usec << 10) | tv.tv_usec);
} else
seed = (unsigned int)time(NULL);
CUtils::GetInput("Listen Host", sListenHost, sListenHost, "Blank for all ips");
CUtils::PrintAction("Verifying the listener");
- CListener* pListener = new CListener(uListenPort, sListenHost, bListenSSL,
+ CListener* pListener = new CListener((unsigned short int)uListenPort, sListenHost, bListenSSL,
b6 ? ADDR_ALL : ADDR_IPV4ONLY, CListener::ACCEPT_ALL);
if (!pListener->Listen()) {
CUtils::PrintStatus(false, FormatBindError());