diff options
-rw-r--r-- | protocols/MSN/src/msn_misc.cpp | 19 | ||||
-rw-r--r-- | protocols/MSN/src/msn_natdetect.cpp | 12 | ||||
-rw-r--r-- | protocols/MSN/src/msn_soapab.cpp | 14 | ||||
-rw-r--r-- | protocols/MSN/src/msn_svcs.cpp | 10 |
4 files changed, 27 insertions, 28 deletions
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index a34a909d06..2b75d3d88e 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -611,15 +611,15 @@ void CMsnProto::MSN_SendStatusMessage(const char* msg) }
else szFormatEnc = HtmlEncodeUTF8T(_T("{0} - {1}"));
- char *szArtist = HtmlEncodeUTF8T(msnCurrentMedia.ptszArtist);
- char *szAlbum = HtmlEncodeUTF8T(msnCurrentMedia.ptszAlbum);
- char *szTitle = HtmlEncodeUTF8T(msnCurrentMedia.ptszTitle);
- char *szTrack = HtmlEncodeUTF8T(msnCurrentMedia.ptszTrack);
- char *szYear = HtmlEncodeUTF8T(msnCurrentMedia.ptszYear);
- char *szGenre = HtmlEncodeUTF8T(msnCurrentMedia.ptszGenre);
- char *szLength = HtmlEncodeUTF8T(msnCurrentMedia.ptszLength);
- char *szPlayer = HtmlEncodeUTF8T(msnCurrentMedia.ptszPlayer);
- char *szType = HtmlEncodeUTF8T(msnCurrentMedia.ptszType);
+ char *szArtist = HtmlEncodeUTF8T(msnCurrentMedia.ptszArtist),
+ *szAlbum = HtmlEncodeUTF8T(msnCurrentMedia.ptszAlbum),
+ *szTitle = HtmlEncodeUTF8T(msnCurrentMedia.ptszTitle),
+ *szTrack = HtmlEncodeUTF8T(msnCurrentMedia.ptszTrack),
+ *szYear = HtmlEncodeUTF8T(msnCurrentMedia.ptszYear),
+ *szGenre = HtmlEncodeUTF8T(msnCurrentMedia.ptszGenre),
+ *szLength = HtmlEncodeUTF8T(msnCurrentMedia.ptszLength),
+ *szPlayer = HtmlEncodeUTF8T(msnCurrentMedia.ptszPlayer),
+ *szType = HtmlEncodeUTF8T(msnCurrentMedia.ptszType);
sz = mir_snprintf(szMsg, SIZEOF(szMsg),
"<Data>"
@@ -640,6 +640,7 @@ void CMsnProto::MSN_SendStatusMessage(const char* msg) mir_free(szLength);
mir_free(szPlayer);
mir_free(szType);
+ mir_free(szFormatEnc);
}
mir_free(msgEnc);
diff --git a/protocols/MSN/src/msn_natdetect.cpp b/protocols/MSN/src/msn_natdetect.cpp index 76bcf7a081..60047bce40 100644 --- a/protocols/MSN/src/msn_natdetect.cpp +++ b/protocols/MSN/src/msn_natdetect.cpp @@ -91,8 +91,6 @@ static void DiscardExtraPackets(SOCKET s) void CMsnProto::MSNatDetect(void)
{
- unsigned i;
-
PHOSTENT host = gethostbyname("echo.edge.messenger.live.com");
if (host == NULL) {
debugLogA("P2PNAT could not find echo server \"echo.edge.messenger.live.com\"");
@@ -109,11 +107,12 @@ void CMsnProto::MSNatDetect(void) addr.sin_addr.S_un.S_un_b.s_b3, addr.sin_addr.S_un.S_un_b.s_b4);
SOCKET s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (connect(s, (SOCKADDR*)&addr, sizeof(addr)) == SOCKET_ERROR) {
+ debugLogA("P2PNAT could not connect to echo server \"echo.edge.messenger.live.com\"");
+ return;
+ }
- connect(s, (SOCKADDR*)&addr, sizeof(addr));
-
- UDPProbePkt pkt = { 0 };
- UDPProbePkt pkt2;
+ UDPProbePkt pkt = { 0 }, pkt2;
// Detect My IP
pkt.version = 2;
@@ -139,6 +138,7 @@ void CMsnProto::MSNatDetect(void) UDPProbePkt rpkt = { 0 };
// NAT detection
+ unsigned i;
for (i = 0; i < 4; ++i) {
if (Miranda_Terminated()) break;
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp index 88acf26373..94764b2f9e 100644 --- a/protocols/MSN/src/msn_soapab.cpp +++ b/protocols/MSN/src/msn_soapab.cpp @@ -150,8 +150,9 @@ bool CMsnProto::MSN_ABAdd(bool allowRecurse) mir_free(abUrl);
abUrl = GetABHost("ABAdd", false);
tResult = getSslResult(&abUrl, szData, reqHdr, status);
- if (tResult == NULL) UpdateABHost("ABAdd", NULL);
- else break;
+ if (tResult)
+ break;
+ UpdateABHost("ABAdd", NULL);
}
mir_free(reqHdr);
@@ -259,16 +260,14 @@ bool CMsnProto::MSN_SharingFindMembership(bool deltas, bool allowRecurse) for (ezxml_t mems = ezxml_get(svcs, "Memberships", 0, "Membership", -1); mems != NULL; mems = ezxml_next(mems)) {
const char* szRole = ezxml_txt(ezxml_child(mems, "MemberRole"));
- int lstId = 0;
- if (strcmp(szRole, "Allow") == 0) lstId = LIST_AL;
- else if (strcmp(szRole, "Block") == 0) lstId = LIST_BL;
- else if (strcmp(szRole, "Reverse") == 0) lstId = LIST_RL;
- else if (strcmp(szRole, "Pending") == 0) lstId = LIST_PL;
+ int lstId = ((strcmp(szRole, "Allow") == 0) ? LIST_AL : ((strcmp(szRole, "Block") == 0) ? LIST_BL :
+ ((strcmp(szRole, "Reverse") == 0) ? LIST_RL : ((strcmp(szRole, "Pending") == 0) ? LIST_PL : 0))));
for (ezxml_t memb = ezxml_get(mems, "Members", 0, "Member", -1); memb != NULL; memb = ezxml_next(memb)) {
bool deleted = strcmp(ezxml_txt(ezxml_child(memb, "Deleted")), "true") == 0;
const char *szType = ezxml_txt(ezxml_child(memb, "Type"));
const char *szInvite = NULL, *szEmail = NULL, *szNick = NULL;
+ char email[128];
int netId;
if (strcmp(szType, "Passport") == 0) {
@@ -285,7 +284,6 @@ bool CMsnProto::MSN_SharingFindMembership(bool deltas, bool allowRecurse) }
else if (strcmp(szType, "Phone") == 0) {
netId = NETID_MOB;
- char email[128];
mir_snprintf(email, SIZEOF(email), "tel:%s", ezxml_txt(ezxml_child(memb, "PhoneNumber")));
szEmail = email;
}
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp index c7beb43a5a..61161e0ea2 100644 --- a/protocols/MSN/src/msn_svcs.cpp +++ b/protocols/MSN/src/msn_svcs.cpp @@ -198,15 +198,15 @@ INT_PTR CMsnProto::SetAvatar(WPARAM, LPARAM lParam) size_t dwPngSize = _filelengthi64(fileId);
unsigned char* pData = (unsigned char*)mir_alloc(dwPngSize);
- if (pData == NULL) return 2;
+ if (pData == NULL) {
+ _close(fileId);
+ return 2;
+ }
_read(fileId, pData, (unsigned)dwPngSize);
_close(fileId);
- TCHAR drive[_MAX_DRIVE];
- TCHAR dir[_MAX_DIR];
- TCHAR fname[_MAX_FNAME];
- TCHAR ext[_MAX_EXT];
+ TCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_tsplitpath(szFileName, drive, dir, fname, ext);
MSN_SetMyAvatar(fname, pData, dwPngSize);
|