diff --git a/modules/dcc.cpp b/modules/dcc.cpp index 9780d3e3..e20f49a8 100644 --- a/modules/dcc.cpp +++ b/modules/dcc.cpp @@ -31,7 +31,7 @@ public: 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; } @@ -58,8 +58,8 @@ protected: 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; @@ -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) { @@ -447,14 +447,14 @@ 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(); @@ -462,7 +462,7 @@ CFile* CDCCSock::OpenFile(bool bWrite) { 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; diff --git a/modules/q.cpp b/modules/q.cpp index 6a7e39e7..ac6a228a 100644 --- a/modules/q.cpp +++ b/modules/q.cpp @@ -443,7 +443,7 @@ private: 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; } diff --git a/modules/sasl.cpp b/modules/sasl.cpp index 890374c3..8eb5f665 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -222,8 +222,7 @@ public: } /* 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; @@ -243,8 +242,7 @@ public: 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; @@ -258,8 +256,7 @@ public: 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; @@ -289,6 +286,7 @@ public: } /* 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); @@ -315,7 +313,7 @@ public: 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); diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index e15bd116..1aba0c99 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -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; } diff --git a/src/main.cpp b/src/main.cpp index dcff4852..10491efb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/znc.cpp b/src/znc.cpp index e3fcefe8..a3ea2fbc 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -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());