Skip to content

Commit

Permalink
Fix more warnings and #197
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthGandalf committed Aug 16, 2012
1 parent 395ae4f commit 892727b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
14 changes: 7 additions & 7 deletions modules/dcc.cpp
Expand Up @@ -31,7 +31,7 @@ class CDCCSock : public CSocket {
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; }
Expand All @@ -58,8 +58,8 @@ class CDCCSock : public CSocket {
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;
Expand Down Expand Up @@ -309,7 +309,7 @@ void CDCCSock::ReadData(const char* data, size_t len) {
} 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) {
Expand Down Expand Up @@ -447,22 +447,22 @@ CFile* CDCCSock::OpenFile(bool bWrite) {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion modules/q.cpp
Expand Up @@ -443,7 +443,7 @@ class CQModule : public CModule {
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;
}
Expand Down
12 changes: 5 additions & 7 deletions modules/sasl.cpp
Expand Up @@ -222,8 +222,7 @@ class CSASLMod : public CModule {
}

/* 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;

Expand All @@ -243,8 +242,7 @@ class CSASLMod : public CModule {
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;

Expand All @@ -258,8 +256,7 @@ class CSASLMod : public CModule {
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;

Expand Down Expand Up @@ -289,6 +286,7 @@ class CSASLMod : public CModule {
}

/* 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);
Expand All @@ -315,7 +313,7 @@ class CSASLMod : public CModule {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/FileUtils.cpp
Expand Up @@ -412,7 +412,7 @@ ssize_t CFile::Write(const char *pszBuffer, size_t iBytes) {
}

ssize_t res = write(m_iFD, pszBuffer, iBytes);
if (res != iBytes)
if (-1 == res)
m_bHadError = true;
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -108,7 +108,7 @@ static void seedPRNG() {

// 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);

Expand Down
2 changes: 1 addition & 1 deletion src/znc.cpp
Expand Up @@ -582,7 +582,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
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());
Expand Down

0 comments on commit 892727b

Please sign in to comment.