diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-15 13:31:23 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-15 13:31:23 +0000 |
commit | 03db06c52cad84ecb2bf0b3fff8a518ff895dc19 (patch) | |
tree | 33051c9755dca9745607c6fafd233fc5f5f307b6 | |
parent | 714b5dfb8f159c8d54ef42c905c3c85f4b4e7962 (diff) |
- crash fix in chats;
- static buffer returned, now with buffer overrun control;
- warnings fixed
git-svn-id: http://svn.miranda-ng.org/main/trunk@13604 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/MSN/src/msn_auth.cpp | 3 | ||||
-rw-r--r-- | protocols/MSN/src/msn_chat.cpp | 22 | ||||
-rw-r--r-- | protocols/MSN/src/msn_commands.cpp | 8 | ||||
-rw-r--r-- | protocols/MSN/src/msn_soapab.cpp | 8 | ||||
-rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 7 |
5 files changed, 24 insertions, 24 deletions
diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 0f3b7a9f4d..27174c1232 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -571,7 +571,8 @@ static int CopyCookies(NETLIBHTTPREQUEST *nlhrReply, NETLIBHTTPHEADER *hdr) if (hdr) {
if (*hdr->szValue) strcat (hdr->szValue, "; ");
strcat (hdr->szValue, nlhrReply->headers[i].szValue);
- } else nSize += strlen(nlhrReply->headers[i].szValue) + 2;
+ }
+ else nSize += (int)strlen(nlhrReply->headers[i].szValue) + 2;
}
return nSize;
}
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index e928f7f403..fd3a260527 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -83,16 +83,16 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p void CMsnProto::MSN_ChatStart(ezxml_t xmli)
{
- const char *pszID, *pszCreator;
- GCThreadData* info;
+ const char *pszCreator;
+
int j;
if (!strcmp(xmli->txt, "thread")) return;
// If Chat ID already exists, don'T create a new one
- pszID = ezxml_txt(ezxml_child(xmli, "id"));
- if (!(*pszID && (info = MSN_GetThreadByChatId(_A2T(pszID)))))
- {
+ const char *pszID = ezxml_txt(ezxml_child(xmli, "id"));
+ GCThreadData* info = MSN_GetThreadByChatId(_A2T(pszID));
+ if (info = NULL) {
info = new GCThreadData;
{
mir_cslock lck(m_csThreads);
@@ -466,17 +466,9 @@ INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l delete cont;
}
else {
- /*
- if (tEmail[0]) cont->insertn(tEmail);
- param->ppro->MsgQueue_Add("chat", 'X', NULL, 0, NULL, 0, cont);
- if (param->ppro->msnLoggedIn)
- param->ppro->msnNsThread->sendPacket("XFR", "SB");
- */
- CMStringA buf;
- int myNetId = param->ppro->GetMyNetID();
-
/* Group chats only work for Skype users */
- buf.AppendFormat("<thread><id></id><members><member><mri>%d:%s</mri><role>admin</role></member>",
+ CMStringA buf;
+ buf.AppendFormat("<thread><id></id><members><member><mri>%d:%s</mri><role>admin</role></member>",
NETID_SKYPE, param->ppro->GetMyUsername(NETID_SKYPE));
for (int i = 0; i < cont->getCount(); ++i) {
// TODO: Add support for assigning role in invite dialog maybe?
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp index 6b9d3e3b2d..116d82c233 100644 --- a/protocols/MSN/src/msn_commands.cpp +++ b/protocols/MSN/src/msn_commands.cpp @@ -323,7 +323,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para }
int msgBytes;
- char *nick = NULL, *email;
+ char *nick = NULL, *email = NULL;
TCHAR *mChatID = NULL;
bool ubmMsg = strncmp(cmdString, "UBM", 3) == 0;
bool sdgMsg = strncmp(cmdString, "SDG", 3) == 0;
@@ -331,8 +331,10 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para if (sdgMsg) {
msgBytes = atol(datas.strMsgBytes);
- if (stricmp(datas.typeId, "MSGR")) return;
- } else {
+ if (stricmp(datas.typeId, "MSGR"))
+ return;
+ }
+ else {
if (ubmMsg) {
msgBytes = atol(datau.strMsgBytes);
nick = datau.fromEmail;
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp index d32301b291..8c79783a06 100644 --- a/protocols/MSN/src/msn_soapab.cpp +++ b/protocols/MSN/src/msn_soapab.cpp @@ -909,19 +909,21 @@ bool CMsnProto::MSN_ABRefreshClist(void) if (mycid && !strcmp(cid, mycid)) continue;
for (ezxml_t cont = ezxml_get(pers, "contacts", 0, "Contact", -1); cont != NULL; cont = ezxml_next(cont)) {
- int netId = NETID_UNKNOWN;
+ int netId;
const char* szEmail;
const char *src = ezxml_txt(ezxml_child(cont, "sourceId"));
if (!strcmp(src, "WL")) {
netId = NETID_MSN;
szEmail = ezxml_txt(ezxml_child(cont, "domainTag"));
- } else if (!strcmp(src, "SKYPE")) {
+ }
+ else if (!strcmp(src, "SKYPE")) {
netId = NETID_SKYPE;
szEmail = ezxml_txt(ezxml_child(cont, "objectId"));
}
+ else continue;
- if (netId == NETID_UNKNOWN || szEmail[0] == 0)
+ if (mir_strlen(szEmail) == 0)
continue;
ezxml_t xmlnick = ezxml_child(pers, "nickname");
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index f9be399735..6a531525a1 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -206,7 +206,8 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) if (info->mBytesInData < msgLen + 2)
break; //wait for full line end
- ptrA msg(mir_strndup(info->mData, msgLen));
+ char msg[1024];
+ strncpy_s(msg, info->mData, _TRUNCATE);
if (*++peol != '\n')
debugLogA("Dodgy line ending to command: ignoring");
@@ -357,8 +358,10 @@ ThreadData* CMsnProto::MSN_GetThreadByContact(const char* wlid, TInfoType type) GCThreadData* CMsnProto::MSN_GetThreadByChatId(const TCHAR* chatId)
{
- mir_cslock lck(m_csThreads);
+ if (mir_tstrlen(chatId) == 0)
+ return NULL;
+ mir_cslock lck(m_csThreads);
for (int i = 0; i < m_arGCThreads.getCount(); i++) {
GCThreadData *T = m_arGCThreads[i];
if (_tcsicmp(T->mChatID, chatId) == 0)
|