summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/IcqOscarJ')
-rw-r--r--protocols/IcqOscarJ/src/fam_17signon.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_avatar.cpp74
-rw-r--r--protocols/IcqOscarJ/src/icq_db.cpp10
-rw-r--r--protocols/IcqOscarJ/src/icq_direct.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_filerequests.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_filetransfer.cpp9
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h26
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp142
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp2
9 files changed, 130 insertions, 141 deletions
diff --git a/protocols/IcqOscarJ/src/fam_17signon.cpp b/protocols/IcqOscarJ/src/fam_17signon.cpp
index 4018aa85a7..a6689e6295 100644
--- a/protocols/IcqOscarJ/src/fam_17signon.cpp
+++ b/protocols/IcqOscarJ/src/fam_17signon.cpp
@@ -120,7 +120,6 @@ void CIcqProto::sendClientAuth(const char *szKey, size_t wKeyLen, BOOL bSecure)
void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread_info *info)
{
- WORD wKeyLen;
char szKey[64] = {0};
mir_md5_state_t state;
BYTE digest[16];
@@ -134,6 +133,7 @@ void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread
return;
}
+ size_t wKeyLen;
unpackWord(&buf, &wKeyLen);
wPacketLen -= 2;
@@ -151,7 +151,7 @@ void CIcqProto::handleAuthKeyResponse(BYTE *buf, size_t wPacketLen, serverthread
mir_md5_finish(&state, digest);
mir_md5_init(&state);
- mir_md5_append(&state, (LPBYTE)szKey, wKeyLen);
+ mir_md5_append(&state, (LPBYTE)szKey, (int)wKeyLen);
mir_md5_append(&state, digest, 16);
mir_md5_append(&state, (LPBYTE)CLIENT_MD5_STRING, sizeof(CLIENT_MD5_STRING)-1);
mir_md5_finish(&state, digest);
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp
index 7d2a5573bf..048195df0b 100644
--- a/protocols/IcqOscarJ/src/icq_avatar.cpp
+++ b/protocols/IcqOscarJ/src/icq_avatar.cpp
@@ -86,13 +86,13 @@ TCHAR* CIcqProto::GetOwnAvatarFileName()
return null_strdup(tmp);
}
-void CIcqProto::GetFullAvatarFileName(int dwUin, const char *szUid, int dwFormat, TCHAR *pszDest, int cbLen)
+void CIcqProto::GetFullAvatarFileName(int dwUin, const char *szUid, int dwFormat, TCHAR *pszDest, size_t cbLen)
{
GetAvatarFileName(dwUin, szUid, pszDest, cbLen);
AddAvatarExt(dwFormat, pszDest);
}
-void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, int cbLen)
+void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, size_t cbLen)
{
TCHAR szPath[MAX_PATH * 2];
mir_sntprintf(szPath, MAX_PATH * 2, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
@@ -103,7 +103,7 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest,
fgd.flags = FF_TCHAR;
// fill the destination
- lstrcpyn(pszDest, szPath, cbLen - 1);
+ mir_tstrncpy(pszDest, szPath, cbLen - 1);
size_t tPathLen = mir_tstrlen(pszDest);
// make sure the avatar cache directory exists
@@ -122,7 +122,8 @@ void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest,
_tcscpy(pszDest + tPathLen, _T("avatar"));
else {
TCHAR *szLastDot = _tcsrchr(szBuf, '.');
- if (szLastDot) szLastDot[0] = '\0';
+ if (szLastDot)
+ szLastDot[0] = '\0';
_tcscpy(pszDest + tPathLen, szBuf);
_tcscat(pszDest + tPathLen, _T("_avt"));
@@ -176,7 +177,7 @@ BYTE* calcMD5HashOfFile(const TCHAR *tszFile)
return res;
}
-int CIcqProto::IsAvatarChanged(MCONTACT hContact, const BYTE *pHash, int nHashLen)
+int CIcqProto::IsAvatarChanged(MCONTACT hContact, const BYTE *pHash, size_t nHashLen)
{
DBVARIANT dbvSaved = { 0 };
if (getSetting(hContact, "AvatarSaved", &dbvSaved))
@@ -250,7 +251,7 @@ void CIcqProto::StopAvatarThread()
}
// handle Owner's avatar hash changes
-void CIcqProto::handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, BYTE nDataLen)
+void CIcqProto::handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, size_t nDataLen)
{
if (nDataLen < 0x14 || !m_bAvatarsEnabled)
return;
@@ -370,13 +371,13 @@ void CIcqProto::handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, BY
}
// handle Contact's avatar hash
-void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hContact, BYTE *pHash, int nHashLen, WORD wOldStatus)
+void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hContact, BYTE *pHash, size_t nHashLen, WORD wOldStatus)
{
int bJob = FALSE;
BOOL avatarInfoPresent = FALSE;
int avatarType = -1;
BYTE *pAvatarHash = NULL;
- int cbAvatarHash;
+ size_t cbAvatarHash;
BYTE emptyItem[0x10] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
if (!m_bAvatarsEnabled || nHashLen < 4)
@@ -384,7 +385,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont
while (nHashLen >= 4) { // parse online message items one by one
WORD itemType = pHash[0] << 8 | pHash[1];
- BYTE itemLen = pHash[3];
+ size_t itemLen = pHash[3];
BYTE itemFlags = pHash[2];
// just some validity check
@@ -539,7 +540,7 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont
}
// request avatar data from server
-int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, unsigned int hashlen, const TCHAR *file)
+int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, size_t hashlen, const TCHAR *file)
{
uid_str szUidData;
char *pszUid = NULL;
@@ -634,12 +635,11 @@ int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid,
}
// upload avatar data to server
-int CIcqProto::SetAvatarData(MCONTACT hContact, WORD wRef, const BYTE *data, unsigned int datalen)
+int CIcqProto::SetAvatarData(MCONTACT hContact, WORD wRef, const BYTE *data, size_t datalen)
{
m_avatarsMutex->Enter();
- if (m_avatarsConnection && m_avatarsConnection->isReady()) // check if we are ready
- {
+ if (m_avatarsConnection && m_avatarsConnection->isReady()) { // check if we are ready
avatars_server_connection *pConnection = m_avatarsConnection;
pConnection->_Lock();
m_avatarsMutex->Leave();
@@ -1051,8 +1051,7 @@ int avatars_server_connection::handleServerPackets(BYTE *buf, size_t buflen)
{
BYTE channel;
WORD sequence;
- WORD datalen;
- int bytesUsed = 0;
+ size_t datalen, bytesUsed = 0;
while (buflen > 0) {
// All FLAPS begin with 0x2a
@@ -1091,7 +1090,7 @@ int avatars_server_connection::handleServerPackets(BYTE *buf, size_t buflen)
bytesUsed += (datalen + 6);
}
- return bytesUsed;
+ return (int)bytesUsed;
}
void avatars_server_connection::handleLoginChannel(BYTE *buf, size_t datalen)
@@ -1354,22 +1353,20 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen
break;
case ICQ_AVATAR_UPLOAD_ACK:
- {
- // upload completed, notify
- BYTE res;
- unpackByte(&pBuffer, &res);
- if (!res && (wBufferLength == 0x15)) {
- if (ppro->FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) // here we store the local hash
- ppro->ReleaseCookie(pSnacHeader->dwRef);
- else
- ppro->debugLogA("Warning: Received unexpected Upload Avatar Reply SNAC(x10,x03).");
- }
- else if (res) {
- ppro->debugLogA("Error uploading avatar to server, #%d", res);
- ppro->icq_LogMessage(LOG_WARNING, LPGEN("Error uploading avatar to server, server refused to accept the image."));
- }
- else ppro->debugLogA("Received invalid upload avatar ack.");
+ // upload completed, notify
+ BYTE res;
+ unpackByte(&pBuffer, &res);
+ if (!res && (wBufferLength == 0x15)) {
+ if (ppro->FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) // here we store the local hash
+ ppro->ReleaseCookie(pSnacHeader->dwRef);
+ else
+ ppro->debugLogA("Warning: Received unexpected Upload Avatar Reply SNAC(x10,x03).");
}
+ else if (res) {
+ ppro->debugLogA("Error uploading avatar to server, #%d", res);
+ ppro->icq_LogMessage(LOG_WARNING, LPGEN("Error uploading avatar to server, server refused to accept the image."));
+ }
+ else ppro->debugLogA("Received invalid upload avatar ack.");
break;
case ICQ_ERROR:
@@ -1383,15 +1380,14 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, size_t wBufferLen
ppro->ReleaseCookie(pSnacHeader->dwRef);
}
- {
- WORD wError;
- if (wBufferLength >= 2)
- unpackWord(&pBuffer, &wError);
- else
- wError = 0;
- ppro->LogFamilyError(ICQ_AVATAR_FAMILY, wError);
- }
+ WORD wError;
+ if (wBufferLength >= 2)
+ unpackWord(&pBuffer, &wError);
+ else
+ wError = 0;
+
+ ppro->LogFamilyError(ICQ_AVATAR_FAMILY, wError);
break;
default:
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp
index e121b6d0d8..4871d2d7b3 100644
--- a/protocols/IcqOscarJ/src/icq_db.cpp
+++ b/protocols/IcqOscarJ/src/icq_db.cpp
@@ -116,12 +116,12 @@ WORD CIcqProto::getContactStatus(MCONTACT hContact)
return getWord(hContact, "Status", ID_STATUS_OFFLINE);
}
-int CIcqProto::getSettingStringStatic(MCONTACT hContact, const char *szSetting, char *dest, int dest_len)
+int CIcqProto::getSettingStringStatic(MCONTACT hContact, const char *szSetting, char *dest, size_t dest_len)
{
- if (!db_get_static(hContact, m_szModuleName, szSetting, dest, dest_len))
+ if (!db_get_static(hContact, m_szModuleName, szSetting, dest, (int)dest_len))
return 0;
- return db_get_static_utf(hContact, m_szModuleName, szSetting, dest, dest_len);
+ return db_get_static_utf(hContact, m_szModuleName, szSetting, dest, (int)dest_len);
}
int CIcqProto::setSettingDouble(MCONTACT hContact, const char *szSetting, double dValue)
@@ -129,9 +129,9 @@ int CIcqProto::setSettingDouble(MCONTACT hContact, const char *szSetting, double
return setSettingBlob(hContact, szSetting, (BYTE*)&dValue, sizeof(double));
}
-int CIcqProto::setSettingBlob(MCONTACT hContact, const char *szSetting, const BYTE *pValue, const int cbValue)
+int CIcqProto::setSettingBlob(MCONTACT hContact, const char *szSetting, const BYTE *pValue, size_t cbValue)
{
- return db_set_blob(hContact, m_szModuleName, szSetting, (void*)pValue, cbValue);
+ return db_set_blob(hContact, m_szModuleName, szSetting, (void*)pValue, (unsigned)cbValue);
}
int CIcqProto::setContactHidden(MCONTACT hContact, BYTE bHidden)
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp
index f1834c6776..bed952d8fe 100644
--- a/protocols/IcqOscarJ/src/icq_direct.cpp
+++ b/protocols/IcqOscarJ/src/icq_direct.cpp
@@ -514,7 +514,6 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen)
unpackLEWord(&buf, &dc->wVersion);
if (dc->wVersion > 6) { // we support only versions 7 and up
- WORD wSecondLen;
DWORD dwUin;
DWORD dwPort;
DWORD dwCookie;
@@ -525,6 +524,7 @@ void CIcqProto::handleDirectPacket(directconnect* dc, PBYTE buf, size_t wLen)
return;
}
+ size_t wSecondLen;
unpackLEWord(&buf, &wSecondLen);
if (wSecondLen && wSecondLen != 0x2b) { // OMG? GnomeICU sets this to zero
NetLog_Direct("Error: Received malformed PEER_INIT");
diff --git a/protocols/IcqOscarJ/src/icq_filerequests.cpp b/protocols/IcqOscarJ/src/icq_filerequests.cpp
index 86b48eeb27..e66aedc990 100644
--- a/protocols/IcqOscarJ/src/icq_filerequests.cpp
+++ b/protocols/IcqOscarJ/src/icq_filerequests.cpp
@@ -124,7 +124,7 @@ void CIcqProto::handleFileRequest(PBYTE buf, size_t wLen, DWORD dwUin, DWORD dwC
wLen -= 4;
// Filename
- WORD wFilenameLength;
+ size_t wFilenameLength;
unpackLEWord(&buf, &wFilenameLength);
if (!wFilenameLength) {
NetLog_Direct("Ignoring malformed file send request");
diff --git a/protocols/IcqOscarJ/src/icq_filetransfer.cpp b/protocols/IcqOscarJ/src/icq_filetransfer.cpp
index df3ffa8c20..32df7bae33 100644
--- a/protocols/IcqOscarJ/src/icq_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/icq_filetransfer.cpp
@@ -292,7 +292,7 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wL
DWORD dwFileCount;
DWORD dwTotalSize;
DWORD dwTransferSpeed;
- WORD wNickLength;
+ size_t wNickLength;
int bAdded;
unpackLEDWord(&buf, &dwFileCount);
@@ -337,16 +337,15 @@ void CIcqProto::handleFileTransferPacket(directconnect* dc, PBYTE buf, size_t wL
return;
buf++; /* id */
{
- char *szAnsi;
- WORD wThisFilenameLen, wSubdirLen;
+ size_t wThisFilenameLen, wSubdirLen;
BYTE isDirectory;
-
unpackByte(&buf, &isDirectory);
unpackLEWord(&buf, &wThisFilenameLen);
if (wLen < 19 + wThisFilenameLen)
return;
+
SAFE_FREE(&dc->ft->szThisFile);
- szAnsi = (char *)_alloca(wThisFilenameLen + 1);
+ char *szAnsi = (char *)_alloca(wThisFilenameLen + 1);
memcpy(szAnsi, buf, wThisFilenameLen);
szAnsi[wThisFilenameLen] = '\0';
dc->ft->szThisFile = ansi_to_utf8(szAnsi);
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h
index d8cea3ae36..82712c208e 100644
--- a/protocols/IcqOscarJ/src/icq_proto.h
+++ b/protocols/IcqOscarJ/src/icq_proto.h
@@ -392,18 +392,18 @@ struct CIcqProto : public PROTO<CIcqProto>
void requestAvatarConnection();
void __cdecl AvatarThread(avatars_server_connection *pInfo);
- void handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, BYTE nDataLen);
- void handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hContact, BYTE *pHash, int nHashLen, WORD wOldStatus);
+ void handleAvatarOwnerHash(WORD wItemID, BYTE bFlags, BYTE *pData, size_t nDataLen);
+ void handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hContact, BYTE *pHash, size_t nHashLen, WORD wOldStatus);
avatars_request *ReleaseAvatarRequestInQueue(avatars_request *request);
TCHAR* GetOwnAvatarFileName();
- void GetFullAvatarFileName(int dwUin, const char *szUid, int dwFormat, TCHAR *pszDest, int cbLen);
- void GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, int cbLen);
- int IsAvatarChanged(MCONTACT hContact, const BYTE *pHash, int nHashLen);
+ void GetFullAvatarFileName(int dwUin, const char *szUid, int dwFormat, TCHAR *pszDest, size_t cbLen);
+ void GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, size_t cbLen);
+ int IsAvatarChanged(MCONTACT hContact, const BYTE *pHash, size_t nHashLen);
- int GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, unsigned int hashlen, const TCHAR *file);
- int SetAvatarData(MCONTACT hContact, WORD wRef, const BYTE *data, unsigned int datalen);
+ int GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, const BYTE *hash, size_t hashlen, const TCHAR *file);
+ int SetAvatarData(MCONTACT hContact, WORD wRef, const BYTE *data, size_t datalen);
void StartAvatarThread(HANDLE hConn, char* cookie, size_t cookieLen);
void StopAvatarThread();
@@ -417,7 +417,7 @@ struct CIcqProto : public PROTO<CIcqProto>
int getSetting(MCONTACT hContact, const char *szSetting, DBVARIANT *dbv);
double getSettingDouble(MCONTACT hContact, const char *szSetting, double dDef);
- int getSettingStringStatic(MCONTACT hContact, const char *szSetting, char *dest, int dest_len);
+ int getSettingStringStatic(MCONTACT hContact, const char *szSetting, char *dest, size_t dest_len);
char* getSettingStringUtf(MCONTACT hContact, const char *szModule, const char *szSetting, char *szDef);
char* getSettingStringUtf(MCONTACT hContact, const char *szSetting, char *szDef);
int getContactUid(MCONTACT hContact, DWORD *pdwUin, uid_str *ppszUid);
@@ -426,7 +426,7 @@ struct CIcqProto : public PROTO<CIcqProto>
char* getContactCListGroup(MCONTACT hContact);
int setSettingDouble(MCONTACT hContact, const char *szSetting, double dValue);
- int setSettingBlob(MCONTACT hContact, const char *szSetting, const BYTE *pValue, const int cbValue);
+ int setSettingBlob(MCONTACT hContact, const char *szSetting, const BYTE *pValue, size_t cbValue);
int setContactHidden(MCONTACT hContact, BYTE bHidden);
void setStatusMsgVar(MCONTACT hContact, char* szStatusMsg, bool isAnsi);
@@ -846,9 +846,9 @@ struct CIcqProto : public PROTO<CIcqProto>
//----| stdpackets.cpp |--------------------------------------------------------------
void __cdecl oft_connectionThread(struct oscarthreadstartinfo *otsi);
- int oft_handlePackets(oscar_connection *oc, BYTE *buf, int len);
- int oft_handleFileData(oscar_connection *oc, BYTE *buf, int len);
- int oft_handleProxyData(oscar_connection *oc, BYTE *buf, int len);
+ int oft_handlePackets(oscar_connection *oc, BYTE *buf, size_t len);
+ int oft_handleFileData(oscar_connection *oc, BYTE *buf, size_t len);
+ int oft_handleProxyData(oscar_connection *oc, BYTE *buf, size_t len);
void oft_sendFileData(oscar_connection *oc);
void oft_sendPeerInit(oscar_connection *oc);
void oft_sendFileReply(DWORD dwUin, char *szUid, oscar_filetransfer *ft, WORD wResult);
@@ -859,7 +859,7 @@ struct CIcqProto : public PROTO<CIcqProto>
//----| utilities.cpp |---------------------------------------------------------------
char* ConvertMsgToUserSpecificAnsi(MCONTACT hContact, const char* szMsg);
- char* GetUserStoredPassword(char *szBuffer, int cbSize);
+ char* GetUserStoredPassword(char *szBuffer, size_t cbSize);
char* GetUserPassword(BOOL bAlways);
WORD GetMyStatusFlags();
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
index 9cc7a54354..c656024087 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
@@ -336,7 +336,6 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
oscar_filetransfer *ft = CreateOscarTransfer();
char *pszFileName = NULL;
char *pszDescription = NULL;
- WORD wFilenameLength;
debugLogA("This is a file request");
@@ -435,7 +434,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
}
BYTE* tBuf = tlv->pData;
- WORD tLen = tlv->wLen;
+ size_t tLen = tlv->wLen;
WORD wFlag;
unpackWord(&tBuf, &wFlag); // FT flag
@@ -444,7 +443,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
tLen -= 8;
// Filename / Directory Name
if (tLen) { // some filename specified, unpack
- wFilenameLength = tLen - 1;
+ size_t wFilenameLength = tLen - 1;
pszFileName = (char*)_alloca(tLen);
unpackString(&tBuf, (char*)pszFileName, wFilenameLength);
pszFileName[wFilenameLength] = '\0';
@@ -622,10 +621,10 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
void CIcqProto::handleRecvServResponseOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *szUID, void* ft)
{
- WORD wDataLen;
-
- if (wLen < 2) return;
+ if (wLen < 2)
+ return;
+ size_t wDataLen;
unpackWord(&buf, &wDataLen);
if (wDataLen == 2) {
@@ -1384,9 +1383,9 @@ void CIcqProto::sendOscarPacket(oscar_connection *oc, icq_packet *packet)
SAFE_FREE((void**)&packet->pData);
}
-int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, int len)
+int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, size_t len)
{
- int bytesUsed = 0;
+ size_t bytesUsed = 0;
while (len > 0) {
if (oc->status == OCS_DATA && (oc->ft->flags & OFTF_FILE_RECEIVING))
@@ -1408,7 +1407,7 @@ int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, int len)
break;
}
- WORD datalen;
+ size_t datalen;
unpackWord(&pBuf, &datalen);
if (len < datalen) // wait for whole packet
@@ -1427,19 +1426,16 @@ int CIcqProto::oft_handlePackets(oscar_connection *oc, BYTE *buf, int len)
bytesUsed += datalen;
}
- return bytesUsed;
+ return (int)bytesUsed;
}
-int CIcqProto::oft_handleProxyData(oscar_connection *oc, BYTE *buf, int len)
+int CIcqProto::oft_handleProxyData(oscar_connection *oc, BYTE *buf, size_t len)
{
oscar_filetransfer *ft = oc->ft;
- BYTE *pBuf;
- WORD datalen;
- WORD wCommand;
- int bytesUsed = 0;
+ size_t datalen, bytesUsed = 0;
while (len > 2) {
- pBuf = buf;
+ BYTE *pBuf = buf;
unpackWord(&pBuf, &datalen);
datalen += 2;
@@ -1452,68 +1448,67 @@ int CIcqProto::oft_handleProxyData(oscar_connection *oc, BYTE *buf, int len)
break;
}
pBuf += 2; // packet version
+
+ WORD wCommand;
unpackWord(&pBuf, &wCommand);
pBuf += 6;
+
// handle packet
switch (wCommand) {
case 0x01: // Error
- {
- WORD wError;
- char* szError;
-
- unpackWord(&pBuf, &wError);
- switch (wError) {
- case 0x0D:
- szError = "Bad request";
- break;
- case 0x0E:
- szError = "Malformed packet";
- break;
- case 0x10:
- szError = "Initial request timeout";
- break;
- case 0x1A:
- szError = "Accept period timeout";
- break;
- case 0x1C:
- szError = "Invalid data";
- break;
+ WORD wError;
+ char* szError;
- default:
- szError = "Unknown";
- }
- // Notify peer
- oft_sendFileResponse(oc->dwUin, oc->szUid, oc->ft, 0x06);
+ unpackWord(&pBuf, &wError);
+ switch (wError) {
+ case 0x0D:
+ szError = "Bad request";
+ break;
+ case 0x0E:
+ szError = "Malformed packet";
+ break;
+ case 0x10:
+ szError = "Initial request timeout";
+ break;
+ case 0x1A:
+ szError = "Accept period timeout";
+ break;
+ case 0x1C:
+ szError = "Invalid data";
+ break;
- debugLogA("Proxy Error: %s (0x%x)", szError, wError);
- // Notify UI
- ProtoBroadcastAck(oc->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, oc->ft, 0);
- // Release structure
- SafeReleaseFileTransfer((void**)&oc->ft);
+ default:
+ szError = "Unknown";
}
+ // Notify peer
+ oft_sendFileResponse(oc->dwUin, oc->szUid, oc->ft, 0x06);
+
+ debugLogA("Proxy Error: %s (0x%x)", szError, wError);
+ // Notify UI
+ ProtoBroadcastAck(oc->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, oc->ft, 0);
+ // Release structure
+ SafeReleaseFileTransfer((void**)&oc->ft);
break;
case 0x03: // Tunnel created
- {
- WORD wCode;
- DWORD dwIP;
-
- unpackWord(&pBuf, &wCode);
- unpackDWord(&pBuf, &dwIP);
-
- if (oc->type == OCT_PROXY_INIT) { // Proxy ready, send Stage 1 Request
- ft->bUseProxy = 1;
- ft->wRemotePort = wCode;
- ft->dwProxyIP = dwIP;
- oft_sendFileRequest(oc->dwUin, oc->szUid, ft, ft->szThisFile, 0);
- SAFE_FREE(&ft->szThisFile);
- // Notify UI
- ProtoBroadcastAck(oc->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, oc->ft, 0);
- }
- else {
- debugLogA("Proxy Tunnel ready, notify peer.");
- oft_sendFileRedirect(oc->dwUin, oc->szUid, ft, dwIP, wCode, TRUE);
- }
+ WORD wCode;
+ DWORD dwIP;
+
+ unpackWord(&pBuf, &wCode);
+ unpackDWord(&pBuf, &dwIP);
+
+ if (oc->type == OCT_PROXY_INIT) { // Proxy ready, send Stage 1 Request
+ ft->bUseProxy = 1;
+ ft->wRemotePort = wCode;
+ ft->dwProxyIP = dwIP;
+ oft_sendFileRequest(oc->dwUin, oc->szUid, ft, ft->szThisFile, 0);
+ SAFE_FREE(&ft->szThisFile);
+ // Notify UI
+ ProtoBroadcastAck(oc->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, oc->ft, 0);
+ }
+ else {
+ debugLogA("Proxy Tunnel ready, notify peer.");
+ oft_sendFileRedirect(oc->dwUin, oc->szUid, ft, dwIP, wCode, TRUE);
}
break;
@@ -1546,14 +1541,13 @@ int CIcqProto::oft_handleProxyData(oscar_connection *oc, BYTE *buf, int len)
bytesUsed += datalen;
}
- return bytesUsed;
+ return (int)bytesUsed;
}
-int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, int len)
+int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, size_t len)
{
oscar_filetransfer *ft = oc->ft;
- DWORD dwLen = len;
- int bytesUsed = 0;
+ size_t dwLen = len, bytesUsed = 0;
// do not accept more data than expected
if (ft->qwThisFileSize - ft->qwFileBytesDone < dwLen)
@@ -1564,9 +1558,9 @@ int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, int len)
return 0;
}
- _write(ft->fileId, buf, dwLen);
+ _write(ft->fileId, buf, (unsigned)dwLen);
// update checksum
- ft->dwRecvFileCheck = oft_calc_checksum((int)ft->qwFileBytesDone, buf, dwLen, ft->dwRecvFileCheck);
+ ft->dwRecvFileCheck = oft_calc_checksum((int)ft->qwFileBytesDone, buf, (unsigned)dwLen, ft->dwRecvFileCheck);
bytesUsed += dwLen;
ft->qwBytesDone += dwLen;
ft->qwFileBytesDone += dwLen;
@@ -1619,7 +1613,7 @@ int CIcqProto::oft_handleFileData(oscar_connection *oc, BYTE *buf, int len)
oc->status = OCS_NEGOTIATION;
}
}
- return bytesUsed;
+ return (int)bytesUsed;
}
void CIcqProto::handleOFT2FramePacket(oscar_connection *oc, WORD datatype, BYTE *pBuffer, size_t wLen)
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index 3fd17d71b7..32e8baa7c8 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -1529,7 +1529,7 @@ char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsiz
return buf;
}
-char* CIcqProto::GetUserStoredPassword(char *szBuffer, int cbSize)
+char* CIcqProto::GetUserStoredPassword(char *szBuffer, size_t cbSize)
{
if (!getSettingStringStatic(NULL, "Password", szBuffer, cbSize))
if (mir_strlen(szBuffer))