summaryrefslogtreecommitdiff
path: root/plugins/Variables/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Variables/src')
-rw-r--r--plugins/Variables/src/contact.cpp17
-rw-r--r--plugins/Variables/src/help.cpp2
-rw-r--r--plugins/Variables/src/parse_alias.cpp7
-rw-r--r--plugins/Variables/src/parse_metacontacts.cpp27
-rw-r--r--plugins/Variables/src/parse_miranda.cpp7
-rw-r--r--plugins/Variables/src/parse_system.cpp5
6 files changed, 37 insertions, 28 deletions
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index 132766ee4d..3c05f4b78b 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -284,11 +284,12 @@ int getContactFromString( CONTACTSINFO* ci )
if (cInfo == NULL) {
// <HANDLE:hContact>
cInfo = (TCHAR*)mir_alloc(32);
- _stprintf(cInfo, _T("%p"), hContact);
- szFind = (TCHAR*)mir_alloc((_tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4)*sizeof(TCHAR));
+ mir_sntprintf(cInfo, 32, _T("%p"), hContact);
+ int size = _tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4;
+ szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL)
{
- wsprintf(szFind, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
+ mir_sntprintf(szFind, size, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
bMatch = TRUE;
@@ -297,11 +298,12 @@ int getContactFromString( CONTACTSINFO* ci )
}
}
else {
- szFind = (TCHAR*)mir_alloc((_tcslen(cInfo) + strlen(szProto) + 4)*sizeof(TCHAR));
+ int size = _tcslen(cInfo) + strlen(szProto) + 4;
+ szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL) {
tszProto = mir_a2t(szProto);
if ((tszProto != NULL) && (szFind != NULL)) {
- wsprintf(szFind, _T("<%s:%s>"), tszProto, cInfo);
+ mir_sntprintf(szFind, size, _T("<%s:%s>"), tszProto, cInfo);
mir_free(cInfo);
mir_free(tszProto);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
@@ -488,7 +490,8 @@ TCHAR *encodeContactToString(HANDLE hContact)
if (szProto == NULL || tszUniqueId == NULL)
return NULL;
- TCHAR *tszResult = (TCHAR*)mir_calloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR));
+ int size = _tcslen(tszUniqueId) + strlen(szProto) + 4;
+ TCHAR *tszResult = (TCHAR *)mir_calloc(size * sizeof(TCHAR));
if (tszResult == NULL)
return NULL;
@@ -497,7 +500,7 @@ TCHAR *encodeContactToString(HANDLE hContact)
if (tszProto == NULL)
return NULL;
- wsprintf(tszResult, _T("<%s:%s>"), tszProto, tszUniqueId);
+ mir_sntprintf(tszResult, size, _T("<%s:%s>"), tszProto, tszUniqueId);
mir_free(tszProto);
diff --git a/plugins/Variables/src/help.cpp b/plugins/Variables/src/help.cpp
index 59476e1a77..2d787e5c09 100644
--- a/plugins/Variables/src/help.cpp
+++ b/plugins/Variables/src/help.cpp
@@ -540,7 +540,7 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam
break;
}
ZeroMemory(tokenString, (len+1)*sizeof(TCHAR));
- wsprintf(tokenString, _T("%c%s%c"), (tr->flags&TRF_FIELD?_T(FIELD_CHAR):_T(FUNC_CHAR)), tr->tszTokenString, (tr->flags&TRF_FIELD?_T(FIELD_CHAR):_T('(')));
+ mir_sntprintf(tokenString, len + 1, _T("%c%s%c"), (tr->flags & TRF_FIELD ? _T(FIELD_CHAR) : _T(FUNC_CHAR)), tr->tszTokenString, (tr->flags & TRF_FIELD ? _T(FIELD_CHAR) : _T('(')));
SendDlgItemMessage(hwndInputDlg, IDC_TESTSTRING, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)tokenString);
mir_free(tokenString);
SetFocus(GetDlgItem(hwndInputDlg, IDC_TESTSTRING));
diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp
index 233a7f761a..3cbae2373e 100644
--- a/plugins/Variables/src/parse_alias.cpp
+++ b/plugins/Variables/src/parse_alias.cpp
@@ -192,16 +192,17 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) {
szArgsA = mir_t2a(szArgs);
- szHelp = ( char* )mir_alloc(32 + strlen(szArgsA));
+ int size = 32 + strlen(szArgsA);
+ szHelp = (char *)mir_alloc(size);
memset(szHelp, '\0', 32 + strlen(szArgsA));
- sprintf(szHelp, LPGEN("Alias")"\t(%s)\t"LPGEN("user defined"), szArgsA);
+ mir_snprintf(szHelp, size, LPGEN("Alias")"\t(%s)\t"LPGEN("user defined"), szArgsA);
res = registerIntToken(alias, parseTranslateAlias, TRF_FUNCTION|TRF_UNPARSEDARGS, szHelp);
mir_free(szArgsA);
}
else {
szHelp = ( char* )mir_alloc(32);
memset(szHelp, '\0', 32);
- sprintf(szHelp, LPGEN("Alias")"\t\t"LPGEN("user defined"));
+ mir_snprintf(szHelp, 32, LPGEN("Alias")"\t\t"LPGEN("user defined"));
res = registerIntToken(alias, parseTranslateAlias, TRF_FIELD|TRF_UNPARSEDARGS, szHelp);
}
mir_free(szArgs);
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp
index dd552ecb9b..40fe04c36b 100644
--- a/plugins/Variables/src/parse_metacontacts.cpp
+++ b/plugins/Variables/src/parse_metacontacts.cpp
@@ -53,13 +53,14 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
if (szUniqueID == NULL)
{
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -67,7 +68,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
@@ -108,13 +109,14 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR* res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -122,7 +124,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
@@ -163,13 +165,14 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), hContact);
+ szUniqueID = (TCHAR *)mir_alloc(32);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -177,7 +180,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp
index c686037325..c3c4eb28b0 100644
--- a/plugins/Variables/src/parse_miranda.cpp
+++ b/plugins/Variables/src/parse_miranda.cpp
@@ -481,12 +481,13 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
szUniqueID = (TCHAR*)mir_alloc(32);
- _stprintf(szUniqueID, _T("%p"), ai->fi->hContact);
+ mir_sntprintf(szUniqueID, 32, _T("%p"), ai->fi->hContact);
if (szProto == NULL || szUniqueID == NULL)
return NULL;
}
- TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ int size = strlen(szProto) + _tcslen(szUniqueID) + 4;
+ TCHAR *res = (TCHAR*)mir_alloc(size * sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
@@ -494,7 +495,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
TCHAR *tszProto = mir_a2t(szProto);
if (tszProto != NULL && szUniqueID != NULL) {
- wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
+ mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
mir_free(szUniqueID);
mir_free(tszProto);
}
diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp
index 67ebf3dd0e..026007a10f 100644
--- a/plugins/Variables/src/parse_system.cpp
+++ b/plugins/Variables/src/parse_system.cpp
@@ -54,11 +54,12 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
if ( _tcslen(ai->targv[1]) == 0)
szCounter = mir_tstrdup(_T("\\Processor(_Total)\\% Processor Time"));
else {
- szCounter = (TCHAR*)mir_alloc((_tcslen(ai->targv[1]) + 32)*sizeof(TCHAR));
+ int size = _tcslen(ai->targv[1]) + 32;
+ szCounter = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szCounter == NULL)
return NULL;
- wsprintf(szCounter, _T("\\Process(%s)\\%% Processor Time"), ai->targv[1]);
+ mir_sntprintf(szCounter, size, _T("\\Process(%s)\\%% Processor Time"), ai->targv[1]);
}
PDH_STATUS pdhStatus = PdhValidatePath(szCounter);
if (pdhStatus != ERROR_SUCCESS) {