diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/PasteIt/src | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PasteIt/src')
-rw-r--r-- | plugins/PasteIt/src/Options.cpp | 24 | ||||
-rw-r--r-- | plugins/PasteIt/src/PasteIt.cpp | 4 | ||||
-rw-r--r-- | plugins/PasteIt/src/PasteToWeb.cpp | 8 | ||||
-rw-r--r-- | plugins/PasteIt/src/PasteToWeb1.cpp | 6 | ||||
-rw-r--r-- | plugins/PasteIt/src/PasteToWeb2.cpp | 2 |
5 files changed, 22 insertions, 22 deletions
diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp index 197d03623b..f7547f8d8d 100644 --- a/plugins/PasteIt/src/Options.cpp +++ b/plugins/PasteIt/src/Options.cpp @@ -799,7 +799,7 @@ void Options::Save() }
buf[j++] = '_';
- mir_strncpy(buf + j, "formats", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "formats", _countof(buf) - j);
std::wstring forms;
for (std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it)
{
@@ -808,30 +808,30 @@ void Options::Save() db_set_ws(0, MODULE, buf, forms.c_str());
- mir_strncpy(buf + j, "defFormatId", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->defFormatId.c_str());
if (webOptions[i]->isSendFileName)
{
- mir_strncpy(buf + j, "sendFileName", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->sendFileName ? 1 : 0);
}
if (webOptions[i]->isPublicPaste)
{
- mir_strncpy(buf + j, "publicPaste", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->publicPaste ? 1 : 0);
}
if (webOptions[i]->isCombo1)
{
- mir_strncpy(buf + j, "combo1", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "combo1", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->combo1.c_str());
}
if (webOptions[i]->isPastebin)
{
- mir_strncpy(buf + j, "pastebinUserKey", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->pastebinUserKey.c_str());
}
}
@@ -868,7 +868,7 @@ void Options::Load() }
buf[j++] = '_';
- mir_strncpy(buf + j, "formats", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "formats", _countof(buf) - j);
DBVARIANT forms;
if (!db_get_ws(0, MODULE, buf, &forms))
{
@@ -899,7 +899,7 @@ void Options::Load() db_free(&forms);
}
- mir_strncpy(buf + j, "defFormatId", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
DBVARIANT defForm;
if (!db_get_ws(0, MODULE, buf, &defForm))
{
@@ -909,19 +909,19 @@ void Options::Load() if (webOptions[i]->isSendFileName)
{
- mir_strncpy(buf + j, "sendFileName", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
webOptions[i]->sendFileName = db_get_b(0, MODULE, buf, 1) ? true : false;
}
if (webOptions[i]->isPublicPaste)
{
- mir_strncpy(buf + j, "publicPaste", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
webOptions[i]->publicPaste = db_get_b(0, MODULE, buf, 0) ? true : false;
}
if (webOptions[i]->isCombo1)
{
- mir_strncpy(buf + j, "combo1", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "combo1", _countof(buf) - j);
DBVARIANT combo1;
if (!db_get_ws(0, MODULE, buf, &combo1))
{
@@ -932,7 +932,7 @@ void Options::Load() if (webOptions[i]->isPastebin)
{
- mir_strncpy(buf + j, "pastebinUserKey", SIZEOF(buf) - j);
+ mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
DBVARIANT pastebinUserKey;
if (!db_get_ws(0, MODULE, buf, &pastebinUserKey))
{
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index 64d458b51b..fce900c8dc 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -72,7 +72,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda std::wstring GetFile()
{
TCHAR filter[512];
- mir_tstrncpy(filter, TranslateT("All Files (*.*)"), SIZEOF(filter));
+ mir_tstrncpy(filter, TranslateT("All Files (*.*)"), _countof(filter));
memcpy(filter + mir_tstrlen(filter), _T("\0*.*\0"), 6 * sizeof(TCHAR));
TCHAR stzFilePath[1024];
stzFilePath[0] = 0;
@@ -84,7 +84,7 @@ std::wstring GetFile() ofn.nFilterIndex = 1;
ofn.lpstrFile = stzFilePath;
ofn.lpstrTitle = TranslateT("Paste It - Select file");
- ofn.nMaxFile = SIZEOF(stzFilePath);
+ ofn.nMaxFile = _countof(stzFilePath);
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
if (GetOpenFileName(&ofn))
{
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp index 9b7a846d07..52f7c8f147 100644 --- a/plugins/PasteIt/src/PasteToWeb.cpp +++ b/plugins/PasteIt/src/PasteToWeb.cpp @@ -384,7 +384,7 @@ void PasteToWeb::FromFile(std::wstring file) {
if (fileSize.QuadPart > 512000LL)
{
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("File size is %d KB, do you really want to paste such a large file?"), fileSize.LowPart / 1024);
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("File size is %d KB, do you really want to paste such a large file?"), fileSize.LowPart / 1024);
if (MessageBox(NULL, bufErr, TranslateT("Are You sure?"), MB_YESNO | MB_ICONQUESTION) != IDYES)
{
CloseHandle(hFile);
@@ -399,7 +399,7 @@ void PasteToWeb::FromFile(std::wstring file) mir_free(fromFileData.content);
fromFileData.content = NULL;
fromFileData.contentLen = 0;
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("Cannot read file '%s'"), file.c_str());
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("Cannot read file '%s'"), file.c_str());
error = bufErr;
}
}
@@ -413,7 +413,7 @@ void PasteToWeb::FromFile(std::wstring file) }
else
{
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("Cannot open file '%s'"), file.c_str());
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("Cannot open file '%s'"), file.c_str());
error = bufErr;
}
@@ -491,7 +491,7 @@ void PasteToWeb::FromFile(std::wstring file) }
else
{
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("File '%s' is empty"), file.c_str());
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("File '%s' is empty"), file.c_str());
error = bufErr;
}
mir_free(fromFileData.content);
diff --git a/plugins/PasteIt/src/PasteToWeb1.cpp b/plugins/PasteIt/src/PasteToWeb1.cpp index 032a7219e2..ecf6dd2055 100644 --- a/plugins/PasteIt/src/PasteToWeb1.cpp +++ b/plugins/PasteIt/src/PasteToWeb1.cpp @@ -304,13 +304,13 @@ void PasteToWeb1::SendToServer(std::wstring str, std::wstring fileName, std::wst {
if (memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("Error during sending text to web page: %s"), resCont + 17);
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("Error during sending text to web page: %s"), resCont + 17);
error = bufErr;
}
else
{
char* s = mir_u2a_cp(resCont, CP_ACP);
- mir_strncpy(szFileLink, s, SIZEOF(szFileLink));
+ mir_strncpy(szFileLink, s, _countof(szFileLink));
mir_free(s);
}
mir_free(resCont);
@@ -336,7 +336,7 @@ std::wstring PasteToWeb1::GetUserKey(std::wstring& user, std::wstring& password) {
if (memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
- mir_sntprintf(bufErr, SIZEOF(bufErr), TranslateT("Error during getting user key from web page: %s"), resCont + 17);
+ mir_sntprintf(bufErr, _countof(bufErr), TranslateT("Error during getting user key from web page: %s"), resCont + 17);
MessageBox(NULL, bufErr, TranslateT("Error"), MB_OK | MB_ICONERROR);
}
else
diff --git a/plugins/PasteIt/src/PasteToWeb2.cpp b/plugins/PasteIt/src/PasteToWeb2.cpp index a7f4c3f0fe..e14db0a966 100644 --- a/plugins/PasteIt/src/PasteToWeb2.cpp +++ b/plugins/PasteIt/src/PasteToWeb2.cpp @@ -121,7 +121,7 @@ void PasteToWeb2::SendToServer(std::wstring str, std::wstring fileName, std::wst if (node != NULL)
{
char* s = mir_t2a_cp(xi.getText(node), CP_ACP);
- mir_strncpy(szFileLink, s, SIZEOF(szFileLink));
+ mir_strncpy(szFileLink, s, _countof(szFileLink));
mir_free(s);
error = NULL;
}
|