summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_adhoc.cpp12
-rw-r--r--protocols/JabberG/src/jabber_file.cpp9
-rw-r--r--protocols/JabberG/src/jabber_icolib.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp5
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp32
-rw-r--r--protocols/JabberG/src/jabber_proxy.cpp6
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp4
-rw-r--r--protocols/JabberG/src/jabber_search.cpp22
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp8
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp2
-rw-r--r--protocols/JabberG/src/jabber_util.cpp11
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp44
12 files changed, 80 insertions, 79 deletions
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp
index 3275897273..c300136881 100644
--- a/protocols/JabberG/src/jabber_adhoc.cpp
+++ b/protocols/JabberG/src/jabber_adhoc.cpp
@@ -160,7 +160,7 @@ int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, Jabbe
code = xmlGetAttrValue(errorNode, _T("code"));
description = xmlGetText(errorNode);
}
- _sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s"), (code) ? code : _T(""), (description) ? description : _T(""));
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s"), (code) ? code : _T(""), (description) ? description : _T(""));
JabberFormSetInstruction(hwndDlg, buff);
}
else if ( !_tcscmp(type, _T("result"))) {
@@ -288,7 +288,7 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberA
code = xmlGetAttrValue(errorNode, _T("code"));
description = xmlGetText(errorNode);
}
- _sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s"),code ? code : _T(""),description?description:_T(""));
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s"), code ? code : _T(""), description ? description : _T(""));
JabberFormSetInstruction(hwndDlg,buff);
}
JabberAdHoc_RefreshFrameScroll(hwndDlg, dat);
@@ -397,8 +397,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
if ( !pStartupParams->m_szNode) {
dat->proto->AdHoc_RequestListOfCommands(pStartupParams->m_szJid, hwndDlg);
- TCHAR Caption[ 512 ];
- _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Jabber Ad-Hoc commands at"), dat->ResponderJID);
+ TCHAR Caption[512];
+ mir_sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Jabber Ad-Hoc commands at"), dat->ResponderJID);
SetWindowText(hwndDlg, Caption);
}
else
@@ -413,8 +413,8 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA
EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
- TCHAR Caption[ 512 ];
- _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Sending Ad-Hoc command to"), dat->ResponderJID);
+ TCHAR Caption[512];
+ mir_sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Sending Ad-Hoc command to"), dat->ResponderJID);
SetWindowText(hwndDlg, Caption);
}
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 7b8282754c..aed856545a 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -297,8 +297,9 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
if (pFileName != NULL) {
int id = SerialNext();
if (ft->iqId) mir_free(ft->iqId);
- ft->iqId = (TCHAR*)mir_alloc(sizeof(TCHAR)*(strlen(JABBER_IQID)+20));
- wsprintf(ft->iqId, _T(JABBER_IQID)_T("%d"), id);
+ size_t size = strlen(JABBER_IQID) + 20;
+ ft->iqId = (TCHAR *)mir_alloc(sizeof(TCHAR) * size);
+ mir_sntprintf(ft->iqId, size, _T(JABBER_IQID)_T("%d"), id);
char *myAddr = NULL;
DBVARIANT dbv;
@@ -317,8 +318,8 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
mir_free(myAddr);
int len = lstrlen(ptszResource) + lstrlen(ft->jid) + 2;
- TCHAR *fulljid = (TCHAR*)alloca(sizeof(TCHAR)*len);
- wsprintf(fulljid, _T("%s/%s"), ft->jid, ptszResource);
+ TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len);
+ mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource);
XmlNodeIq iq(_T("set"), id, fulljid);
HXML query = iq << XQUERY(JABBER_FEAT_OOB);
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp
index cc445c421d..a9f1f5be19 100644
--- a/protocols/JabberG/src/jabber_icolib.cpp
+++ b/protocols/JabberG/src/jabber_icolib.cpp
@@ -277,8 +277,8 @@ static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectNa
GetModuleFileNameA(NULL, szPath, MAX_PATH);
str=strrchr(szPath,'\\');
if (str != NULL) *str=0;
- _snprintf(szMyPath, sizeof(szMyPath), "%s\\Icons\\%s", szPath, filename);
- _snprintf(szFullPath, sizeof(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
+ mir_snprintf(szMyPath, sizeof(szMyPath), "%s\\Icons\\%s", szPath, filename);
+ mir_snprintf(szFullPath, sizeof(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
BOOL nf;
HICON hi=ExtractIconFromPath(szFullPath,&nf);
if (hi) has_proto_icon=TRUE;
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index dfacdd5bba..24d72a83f6 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -118,7 +118,6 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
#define StringCchCopy(x,y,z) lstrcpyn((x),(z),(y))
#define StringCchCat(x,y,z) lstrcat((x),(z))
-#define StringCchPrintf mir_sntprintf
// slightly modified sample from MSDN
BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE)
@@ -339,7 +338,7 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE)
TCHAR buf[80];
- StringCchPrintf(buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
+ mir_sntprintf(buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
StringCchCat(pszOS, BUFSIZE, buf);
return TRUE;
@@ -780,7 +779,7 @@ BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams)
{
CLISTEVENT cle = {0};
char szService[256];
- mir_snprintf(szService, sizeof(szService),"%s%s", m_szModuleName, JS_HTTP_AUTH);
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, JS_HTTP_AUTH);
cle.cbSize = sizeof(CLISTEVENT);
cle.hIcon = (HICON) LoadIconEx("openid");
cle.flags = CLEF_PROTOCOLGLOBAL | CLEF_TCHAR;
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 60517cc113..f584333bbe 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -791,13 +791,13 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
if (nEmail == 0)
strcpy(text, "e-mail");
else
- sprintf(text, "e-mail%d", nEmail-1);
+ mir_snprintf(text, SIZEOF(text), "e-mail%d", nEmail - 1);
}
- else sprintf(text, "e-mail%d", nEmail);
+ else mir_snprintf(text, SIZEOF(text), "e-mail%d", nEmail);
setTString(hContact, text, xmlGetText(m));
if (hContact == NULL) {
- sprintf(text, "e-mailFlag%d", nEmail);
+ mir_snprintf(text, SIZEOF(text), "e-mailFlag%d", nEmail);
int nFlag = 0;
if (xmlGetChild(n, "HOME") != NULL) nFlag |= JABBER_VCEMAIL_HOME;
if (xmlGetChild(n, "WORK") != NULL) nFlag |= JABBER_VCEMAIL_WORK;
@@ -963,11 +963,11 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
}
}
else {
- char text[ 100 ];
- sprintf(text, "Phone%d", nPhone);
+ char text[100];
+ mir_snprintf(text, SIZEOF(text), "Phone%d", nPhone);
setTString(text, xmlGetText(m));
- sprintf(text, "PhoneFlag%d", nPhone);
+ mir_snprintf(text, SIZEOF(text), "PhoneFlag%d", nPhone);
int nFlag = 0;
if (xmlGetChild(n,"HOME") != NULL) nFlag |= JABBER_VCTEL_HOME;
if (xmlGetChild(n,"WORK") != NULL) nFlag |= JABBER_VCTEL_WORK;
@@ -1049,8 +1049,8 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
if (nEmail <= 0)
delSetting(hContact, "e-mail");
else {
- char text[ 100 ];
- sprintf(text, "e-mail%d", nEmail-1);
+ char text[100];
+ mir_snprintf(text, SIZEOF(text), "e-mail%d", nEmail - 1);
if ( db_get_s(hContact, m_szModuleName, text, &dbv)) break;
db_free(&dbv);
delSetting(hContact, text);
@@ -1060,12 +1060,12 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
}
else {
while (true) {
- char text[ 100 ];
- sprintf(text, "e-mail%d", nEmail);
+ char text[100];
+ mir_snprintf(text, SIZEOF(text), "e-mail%d", nEmail);
if ( getString(text, &dbv)) break;
db_free(&dbv);
delSetting(text);
- sprintf(text, "e-mailFlag%d", nEmail);
+ mir_snprintf(text, SIZEOF(text), "e-mailFlag%d", nEmail);
delSetting(text);
nEmail++;
} }
@@ -1093,12 +1093,12 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode)
}
else {
while (true) {
- char text[ 100 ];
- sprintf(text, "Phone%d", nPhone);
+ char text[100];
+ mir_snprintf(text, SIZEOF(text), "Phone%d", nPhone);
if ( getString(text, &dbv)) break;
db_free(&dbv);
delSetting(text);
- sprintf(text, "PhoneFlag%d", nPhone);
+ mir_snprintf(text, SIZEOF(text), "PhoneFlag%d", nPhone);
delSetting(text);
nPhone++;
} }
@@ -1474,14 +1474,14 @@ LBL_ErrFormat:
setByte(hContact, "AvatarType", pictureType);
- char buffer[ 41 ];
+ char buffer[41];
mir_sha1_byte_t digest[20];
mir_sha1_ctx sha;
mir_sha1_init(&sha);
mir_sha1_append(&sha, (mir_sha1_byte_t*)(char*)body, resultLen);
mir_sha1_finish(&sha, digest);
for (int i=0; i<20; i++)
- sprintf(buffer+(i<<1), "%02x", digest[i]);
+ mir_snprintf(buffer + (i << 1), 2, "%02x", digest[i]);
GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
_tcsncpy(AI.filename, tszFileName, SIZEOF(AI.filename));
diff --git a/protocols/JabberG/src/jabber_proxy.cpp b/protocols/JabberG/src/jabber_proxy.cpp
index 8f7308fff8..1bcf6d7e32 100644
--- a/protocols/JabberG/src/jabber_proxy.cpp
+++ b/protocols/JabberG/src/jabber_proxy.cpp
@@ -55,7 +55,7 @@ int JabberHttpGatewayInit(HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/, NETL
unpackDWord(&buf, &dwSid2);
unpackDWord(&buf, &dwSid3);
unpackDWord(&buf, &dwSid4);
- sprintf(szSid, "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4);
+ mir_snprintf(szSid, SIZEOF(szSid), "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4);
unpackWord(&buf, &wIpLen);
if (responseBytes < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof(szHttpServer) - 1)
{
@@ -70,8 +70,8 @@ int JabberHttpGatewayInit(HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/, NETL
nlhpi.szHttpGetUrl = szHttpGetUrl;
nlhpi.szHttpPostUrl = szHttpPostUrl;
nlhpi.firstPostSequence = 1;
- sprintf(szHttpGetUrl, "http://%s/monitor?sid=%s", szHttpServer, szSid);
- sprintf(szHttpPostUrl, "http://%s/data?sid=%s&seq=", szHttpServer, szSid);
+ mir_snprintf(szHttpGetUrl, SIZEOF(szHttpGetUrl), "http://%s/monitor?sid=%s", szHttpServer, szSid);
+ mir_snprintf(szHttpPostUrl, SIZEOF(szHttpPostUrl), "http://%s/data?sid=%s&seq=", szHttpServer, szSid);
return CallService(MS_NETLIB_SETHTTPPROXYINFO, (WPARAM)hConn, (LPARAM)&nlhpi);
#endif
return 1;
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 0dd007b05c..5990dad83b 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -587,8 +587,8 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
time_t ltime = (time_t)dbei.timestamp;
struct tm *gmt = gmtime(&ltime);
- TCHAR stime[ 512 ];
- wsprintf(stime, _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
+ TCHAR stime[512];
+ mir_sntprintf(stime, SIZEOF(stime), _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index 49f946cd42..5393322265 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -191,7 +191,7 @@ void CJabberProto::OnIqResultGetSearchFields(HXML iqNode)
code = xmlGetAttrValue(errorNode, _T("code"));
description = xmlGetText(errorNode);
}
- _sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nPlease select other server"),code ? code : _T(""),description?description:_T(""));
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s\r\nPlease select other server"), code ? code : _T(""), description ? description : _T(""));
SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff);
}
else SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, TranslateT("Error Unknown reply recieved\r\nPlease select other server"));
@@ -269,7 +269,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M
int k=0;
while (nickfields[k] && !nick) nick=pmUserData->operator [](nickfields[k++]);
if (_tcsicmp(nick, Results.jsr.jid))
- _sntprintf(buff,SIZEOF(buff),_T("%s (%s)"),nick, Results.jsr.jid);
+ mir_sntprintf(buff, SIZEOF(buff), _T("%s (%s)"), nick, Results.jsr.jid);
else
_tcsncpy(buff, nick, SIZEOF(buff));
Results.jsr.hdr.nick = nick ? buff : NULL;
@@ -378,7 +378,7 @@ void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode)
description = xmlGetText(errorNode);
}
- _sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nTry to specify more detailed"),code ? code : _T(""),description?description:_T(""));
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s\r\nTry to specify more detailed"), code ? code : _T(""), description ? description : _T(""));
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
if (searchHandleDlg)
SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff);
@@ -486,20 +486,20 @@ void CJabberProto::SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFr
char key[30];
//search in recent
for (int i=0; i<10; i++) {
- sprintf(key,"RecentlySearched_%d",i);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i);
if ( !getTString(key, &dbv)) {
if ( !_tcsicmp(szAddr, dbv.ptszVal)) {
db_free(&dbv);
for (int j=i; j<10; j++) {
- sprintf(key, "RecentlySearched_%d", j+1);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j + 1);
if ( !getTString(key, &dbv)) {
- sprintf(key,"RecentlySearched_%d",j);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
setTString(NULL,key,dbv.ptszVal);
db_free(&dbv);
}
else {
if (deleteLastFromDB) {
- sprintf(key,"RecentlySearched_%d",j);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
delSetting(NULL,key);
}
break;
@@ -515,14 +515,14 @@ void CJabberProto::SearchAddToRecent(const TCHAR *szAddr, HWND hwndDialog)
char key[30];
SearchDeleteFromRecent(szAddr);
for (int j=9; j > 0; j--) {
- sprintf(key, "RecentlySearched_%d", j-1);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j - 1);
if ( !getTString(key, &dbv)) {
- sprintf(key,"RecentlySearched_%d",j);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
setTString(NULL,key,dbv.ptszVal);
db_free(&dbv);
} }
- sprintf(key, "RecentlySearched_%d", 0);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", 0);
setTString(key, szAddr);
if (hwndDialog)
JabberSearchAddUrlToRecentCombo(hwndDialog, szAddr);
@@ -555,7 +555,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR
DBVARIANT dbv;
for (i=0; i < 10; i++) {
char key[30];
- sprintf(key,"RecentlySearched_%d",i);
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i);
if ( !dat->ppro->getTString(key, &dbv)) {
JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal);
db_free(&dbv);
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index 251e875fd3..72068c9d95 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -177,7 +177,7 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
mir_md5_state_t ctx;
CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
- sprintf(cnonce, "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
+ mir_snprintf(cnonce, SIZEOF(cnonce), "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
ptrA uname( mir_utf8encodeT(info->username)),
passw( mir_utf8encodeT(info->password)),
@@ -205,15 +205,15 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
mir_md5_finish(&ctx, (BYTE*)hash2);
mir_md5_init(&ctx);
- sprintf(tmpBuf, "%08x%08x%08x%08x", htonl(hash1[0]), htonl(hash1[1]), htonl(hash1[2]), htonl(hash1[3]));
+ mir_snprintf(tmpBuf, SIZEOF(tmpBuf), "%08x%08x%08x%08x", htonl(hash1[0]), htonl(hash1[1]), htonl(hash1[2]), htonl(hash1[3]));
mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
mir_md5_append(&ctx, (BYTE*)":", 1);
mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
- sprintf(tmpBuf, ":%08d:", iCallCount);
+ mir_snprintf(tmpBuf, SIZEOF(tmpBuf), ":%08d:", iCallCount);
mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
mir_md5_append(&ctx, (BYTE*)cnonce, (int)strlen(cnonce));
mir_md5_append(&ctx, (BYTE*)":auth:", 6);
- sprintf(tmpBuf, "%08x%08x%08x%08x", htonl(hash2[0]), htonl(hash2[1]), htonl(hash2[2]), htonl(hash2[3]));
+ mir_snprintf(tmpBuf, SIZEOF(tmpBuf), "%08x%08x%08x%08x", htonl(hash2[0]), htonl(hash2[1]), htonl(hash2[2]), htonl(hash2[3]));
mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
mir_md5_finish(&ctx, (BYTE*)digest);
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 60978c69f3..6dd9166276 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -325,7 +325,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
char buf[MIR_SHA1_HASH_SIZE*2+1];
for (int i=0; i<MIR_SHA1_HASH_SIZE; i++)
- sprintf(buf+(i<<1), "%02x", digest[i]);
+ mir_snprintf(buf + (i << 1), 2, "%02x", digest[i]);
m_options.AvatarType = ProtoGetBufferFormat(pResult);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 2a319cd7ea..f9488f09d9 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -350,7 +350,7 @@ char* __stdcall JabberSha1(char* str)
char *result = (char*)mir_alloc(41);
if (result)
for (int i=0; i < 20; i++)
- sprintf(result+(i<<1), "%02x", digest[i]);
+ mir_snprintf(result + (i << 1), 2, "%02x", digest[i]);
return result;
}
@@ -442,13 +442,14 @@ TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str)
TCHAR *p, *q, *res;
if (str == NULL) return NULL;
- res = (TCHAR*) mir_alloc(3*_tcslen(str) + 1);
+ size_t size = 3 * _tcslen(str) + 1;
+ res = (TCHAR *)mir_alloc(size);
for (p = (TCHAR*)str, q = res; *p!='\0'; p++,q++) {
if ((*p>='A' && *p<='Z') || (*p>='a' && *p<='z') || (*p>='0' && *p<='9') || strchr("$-_.+!*'(),", *p) != NULL) {
*q = *p;
}
else {
- wsprintf(q, _T("%%%02X"), *p);
+ mir_sntprintf(q, size, _T("%%%02X"), *p);
q += 2;
}
}
@@ -886,7 +887,7 @@ void __stdcall JabberStringAppend(char* *str, int *sizeAlloced, const char* fmt,
p = *str + len;
va_start(vararg, fmt);
- while (_vsnprintf(p, size, fmt, vararg) == -1) {
+ while (mir_vsnprintf(p, size, fmt, vararg) == -1) {
size += 2048;
(*sizeAlloced) += 2048;
*str = (char*)mir_realloc(*str, *sizeAlloced);
@@ -1651,7 +1652,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
mir_sha1_append(&sha, (mir_sha1_byte_t*)res->pData, res->dataLength);
mir_sha1_finish(&sha, digest);
for (int i=0; i<20; i++)
- sprintf(buffer+(i<<1), "%02x", digest[i]);
+ mir_snprintf(buffer + (i << 1), 2, "%02x", digest[i]);
ptrA cmpsha( getStringA(AI.hContact, "AvatarSaved"));
if (cmpsha == NULL || strnicmp(cmpsha, buffer, sizeof(buffer))) {
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 08b1e70b13..d916441f3c 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -565,11 +565,11 @@ static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
WORD nFlag;
SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Email Address"));
- wsprintfA(idstr, "e-mail%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
if ( !dat->ppro->getString(idstr, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
- wsprintfA(idstr, "e-mailFlag%d", lParam);
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", lParam);
nFlag = dat->ppro->getWord(idstr, 0);
if (nFlag & JABBER_VCEMAIL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
if (nFlag & JABBER_VCEMAIL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
@@ -631,11 +631,11 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
WORD nFlag;
SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Phone Number"));
- wsprintfA(idstr, "Phone%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
if ( !dat->ppro->getString(idstr, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_PHONE, dbv.pszVal);
db_free(&dbv);
- wsprintfA(idstr, "PhoneFlag%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
nFlag = dat->ppro->getWord(idstr, 0);
if (nFlag & JABBER_VCTEL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
if (nFlag & JABBER_VCTEL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
@@ -663,13 +663,13 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (dat->id < 0) {
for (dat->id=0;;dat->id++) {
- wsprintfA(idstr, "Phone%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
if ( dat->ppro->getString(idstr, &dbv)) break;
db_free(&dbv);
}
}
GetDlgItemTextA(hwndDlg, IDC_PHONE, text, SIZEOF(text));
- wsprintfA(idstr, "Phone%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
dat->ppro->setString(idstr, text);
nFlag = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
@@ -684,7 +684,7 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (IsDlgButtonChecked(hwndDlg, IDC_MODEM)) nFlag |= JABBER_VCTEL_MODEM;
if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
- wsprintfA(idstr, "PhoneFlag%d", dat->id);
+ mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
dat->ppro->setWord(idstr, nFlag);
}
// fall through
@@ -746,9 +746,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
lvi.iSubItem = 0;
lvi.iItem = 0;
for (i=0;;i++) {
- wsprintfA(idstr, "e-mail%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
if ( ppro->getTString(idstr, &dbv)) break;
- wsprintf(number, _T("%d"), i+1);
+ mir_sntprintf(number, SIZEOF(number), _T("%d"), i+1);
lvi.pszText = number;
lvi.lParam = (LPARAM)i;
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
@@ -765,9 +765,9 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
lvi.iSubItem = 0;
lvi.iItem = 0;
for (i=0;;i++) {
- wsprintfA(idstr, "Phone%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
if ( ppro->getTString(idstr, &dbv)) break;
- wsprintf(number, _T("%d"), i+1);
+ mir_sntprintf(number, SIZEOF(number), _T("%d"), i+1);
lvi.pszText = number;
lvi.lParam = (LPARAM)i;
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
@@ -872,19 +872,19 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP
for (i=lvi.lParam;;i++) {
WORD nFlag;
- wsprintfA(idstr, szIdTemplate, i+1);
+ mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i + 1);
if (ppro->getString(idstr, &dbv)) break;
- wsprintfA(idstr,szIdTemplate,i);
+ mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
ppro->setString(idstr, dbv.pszVal);
- wsprintfA(idstr, szFlagTemplate, i+1);
+ mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i + 1);
db_free(&dbv);
nFlag = ppro->getWord(idstr, 0);
- wsprintfA(idstr, szFlagTemplate, i);
+ mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i);
ppro->setWord(idstr, nFlag);
}
- wsprintfA(idstr, szIdTemplate, i);
+ mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
ppro->delSetting(idstr);
- wsprintfA(idstr, szFlagTemplate, i);
+ mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i);
ppro->delSetting(idstr);
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
ppro->m_vCardUpdates |= (1UL<<iPageId);
@@ -1057,7 +1057,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "GENDER", "GenderString");
for (i=0;;i++) {
- wsprintfA(idstr, "e-mail%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
if ( getTString(idstr, &dbv))
break;
@@ -1065,7 +1065,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
db_free(&dbv);
AppendVcardFromDB(e, "USERID", idstr);
- wsprintfA(idstr, "e-mailFlag%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", i);
nFlag = getWord(idstr, 0);
if (nFlag & JABBER_VCEMAIL_HOME) e << XCHILD(_T("HOME"));
if (nFlag & JABBER_VCEMAIL_WORK) e << XCHILD(_T("WORK"));
@@ -1105,14 +1105,14 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
AppendVcardFromDB(v, "DESC", "About");
for (i=0;;i++) {
- wsprintfA(idstr, "Phone%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
if ( getTString(idstr, &dbv)) break;
db_free(&dbv);
n = v << XCHILD(_T("TEL"));
AppendVcardFromDB(n, "NUMBER", idstr);
- wsprintfA(idstr, "PhoneFlag%d", i);
+ mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", i);
nFlag = getWord(idstr, 0);
if (nFlag & JABBER_VCTEL_HOME) n << XCHILD(_T("HOME"));
if (nFlag & JABBER_VCTEL_WORK) n << XCHILD(_T("WORK"));
@@ -1179,7 +1179,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
char buf[MIR_SHA1_HASH_SIZE*2+1];
for (int j=0; j<MIR_SHA1_HASH_SIZE; j++)
- sprintf(buf+(j<<1), "%02x", digest[j]);
+ mir_snprintf(buf + (j << 1), 2, "%02x", digest[j]);
m_options.AvatarType = ProtoGetBufferFormat(buffer);