diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-13 08:01:55 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-13 08:01:55 +0000 |
commit | 303e6b483aff4126701ca375dd085e9ae1d18b43 (patch) | |
tree | 148d820728544a5fd6f6e87fdffbc5b80424c457 | |
parent | cce79a92d5341111997eaf7fd0a420fdddc3e50d (diff) |
multiple buf size fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@11361 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/AutoShutdown/src/utils.cpp | 11 | ||||
-rw-r--r-- | plugins/AvatarHistory/src/AvatarDlg.cpp | 2 | ||||
-rw-r--r-- | plugins/AvatarHistory/src/AvatarHistory.cpp | 12 | ||||
-rw-r--r-- | plugins/FileAsMessage/src/dialog.cpp | 21 | ||||
-rw-r--r-- | plugins/Utils/mir_fonts.cpp | 11 | ||||
-rw-r--r-- | plugins/YAMN/src/browser/badconnect.cpp | 6 | ||||
-rw-r--r-- | protocols/SkypeClassic/src/skypeprofile.cpp | 12 | ||||
-rw-r--r-- | src/mir_core/langpack.cpp | 2 | ||||
-rw-r--r-- | src/modules/chat/chat_opts.cpp | 6 | ||||
-rw-r--r-- | src/modules/clist/clisttray.cpp | 4 |
10 files changed, 46 insertions, 41 deletions
diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp index 7eeab7d78f..4335dd7566 100644 --- a/plugins/AutoShutdown/src/utils.cpp +++ b/plugins/AutoShutdown/src/utils.cpp @@ -260,12 +260,13 @@ int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,cons int FontService_GetColor(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr)
{
ColourIDT cid;
+
memset(&cid, 0, sizeof(cid));
- cid.cbSize=sizeof(cid);
- mir_tstrncpy(cid.group,pszSection,sizeof(cid.group)); /* buffer safe */
- mir_tstrncpy(cid.name,pszDescription,sizeof(cid.name)); /* buffer safe */
- *pclr=(COLORREF)CallService(MS_COLOUR_GETT,(WPARAM)&cid,0);
- return (int)*pclr==-1;
+ cid.cbSize = sizeof(cid);
+ _tcsncpy_s(cid.group, pszSection, _TRUNCATE);
+ _tcsncpy_s(cid.name, pszDescription, _TRUNCATE);
+ *pclr = (COLORREF)CallService(MS_COLOUR_GETT, (WPARAM)&cid, 0);
+ return (int)*pclr == -1;
}
/************************* Skin ***********************************/
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index 491d3d34be..64ac70749d 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -554,7 +554,7 @@ int ShowSaveDialog(HWND hwnd, TCHAR* fn, MCONTACT hContact) ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
- mir_tstrncpy(file, _tcsrchr(fn, '\\')+1, sizeof(file));
+ _tcsncpy_s(file, (_tcsrchr(fn, '\\') + 1), _TRUNCATE);
ofn.lpstrFile = file;
TCHAR *displayName = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,GCDNF_TCHAR);
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index cd3489212b..1f98aa149a 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -75,9 +75,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) static INT_PTR GetCachedAvatar(WPARAM wParam, LPARAM lParam)
{
TCHAR hash[128];
- mir_tstrncpy(hash, (TCHAR *) lParam, sizeof(hash));
- ConvertToFilename(hash, sizeof(hash));
- return (INT_PTR) GetCachedAvatar((char *) wParam, hash);
+
+ _tcsncpy_s(hash, (TCHAR*)lParam, _TRUNCATE);
+ ConvertToFilename(hash, SIZEOF(hash));
+ return (INT_PTR)GetCachedAvatar((char*)wParam, hash);
}
static INT_PTR IsEnabled(WPARAM wParam, LPARAM lParam)
@@ -169,8 +170,9 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam) else {
// See if we already have the avatar
TCHAR hash[128];
- mir_tstrncpy(hash, avatar->hash, sizeof(hash));
- ConvertToFilename(hash, sizeof(hash));
+
+ _tcsncpy_s(hash, avatar->hash, _TRUNCATE);
+ ConvertToFilename(hash, SIZEOF(hash));
TCHAR *file = GetCachedAvatar(proto, hash);
diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp index 9cc63c3929..2b144d6048 100644 --- a/plugins/FileAsMessage/src/dialog.cpp +++ b/plugins/FileAsMessage/src/dialog.cpp @@ -884,16 +884,19 @@ int FILEECHO::sendCmd(int id, int cmd, char *szParam, char *szPrefix) void CreateDirectoryTree(char *szDir)
{
DWORD dwAttributes;
- char *pszLastBackslash,szTestDir[MAX_PATH];
-
- mir_tstrncpy(szTestDir,szDir,sizeof(szTestDir));
- if((dwAttributes=GetFileAttributes(szTestDir))!=0xffffffff
- && dwAttributes&FILE_ATTRIBUTE_DIRECTORY) return;
- pszLastBackslash=strrchr(szTestDir,'\\');
- if(pszLastBackslash==NULL) {GetCurrentDirectory(MAX_PATH,szDir); return;}
- *pszLastBackslash='\0';
+ char *pszLastBackslash, szTestDir[MAX_PATH];
+
+ strncpy_s(szTestDir, szDir, _TRUNCATE);
+ if((dwAttributes = GetFileAttributes(szTestDir)) != 0xffffffff && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ return;
+ pszLastBackslash = strrchr(szTestDir, '\\');
+ if (pszLastBackslash == NULL) {
+ GetCurrentDirectory(MAX_PATH, szDir);
+ return;
+ }
+ *pszLastBackslash = 0;
CreateDirectoryTree(szTestDir);
- CreateDirectory(szTestDir,NULL);
+ CreateDirectory(szTestDir, NULL);
}
LRESULT CALLBACK ProgressWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Utils/mir_fonts.cpp b/plugins/Utils/mir_fonts.cpp index 237eb040f7..768ac12363 100644 --- a/plugins/Utils/mir_fonts.cpp +++ b/plugins/Utils/mir_fonts.cpp @@ -60,10 +60,11 @@ int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,cons int FontService_GetColor(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr)
{
ColourIDT cid;
+
memset(&cid, 0, sizeof(cid));
- cid.cbSize=sizeof(cid);
- mir_tstrncpy(cid.group,pszSection,sizeof(cid.group)); /* buffer safe */
- mir_tstrncpy(cid.name,pszDescription,sizeof(cid.name)); /* buffer safe */
- *pclr=(COLORREF)CallService(MS_COLOUR_GETT,(WPARAM)&cid,0);
- return (int)*pclr==-1;
+ cid.cbSize = sizeof(cid);
+ _tcsncpy_s(cid.group, pszSection, _TRUNCATE);
+ _tcsncpy_s(cid.name, pszDescription, _TRUNCATE);
+ *pclr = (COLORREF)CallService(MS_COLOUR_GETT, (WPARAM)&cid, 0);
+ return (int)*pclr == -1;
}
diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index eeccc75553..6339ebaba5 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -125,7 +125,7 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARA if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) {
Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- mir_tstrncpy(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
if (ShowPopup)
PUAddPopupT(&BadConnectPopup);
}
@@ -133,7 +133,7 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARA {
Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- mir_tstrncpy(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
if (ShowPopup)
PUAddPopupT(&BadConnectPopup);
}
@@ -141,7 +141,7 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARA {
Message1W=TranslateT("Unknown error");
SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- mir_tstrncpy(BadConnectPopup.lptzText,Message1W,sizeof(BadConnectPopup.lptzText));
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
if (ShowPopup)
PUAddPopupT(&BadConnectPopup);
}
diff --git a/protocols/SkypeClassic/src/skypeprofile.cpp b/protocols/SkypeClassic/src/skypeprofile.cpp index 51faa34b55..045a5b7d78 100644 --- a/protocols/SkypeClassic/src/skypeprofile.cpp +++ b/protocols/SkypeClassic/src/skypeprofile.cpp @@ -30,32 +30,32 @@ void SkypeProfile_Load(SkypeProfile *pstProf) DBVARIANT dbv;
if(!db_get_ts(NULL,SKYPE_PROTONAME,"Nick",&dbv))
{
- _tcsncpy (pstProf->FullName, dbv.ptszVal, sizeof(pstProf->FullName)/sizeof(TCHAR));
+ _tcsncpy_s(pstProf->FullName, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
}
if(!db_get_s(NULL,SKYPE_PROTONAME,"HomePage",&dbv))
{
- strncpy (pstProf->HomePage, dbv.pszVal, sizeof(pstProf->HomePage));
+ strncpy_s(pstProf->HomePage, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
}
if(!db_get_ts(NULL,SKYPE_PROTONAME,"Province",&dbv))
{
- _tcsncpy (pstProf->Province, dbv.ptszVal, sizeof(pstProf->Province)/sizeof(TCHAR));
+ _tcsncpy_s(pstProf->Province, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
}
if(!db_get_ts(NULL,SKYPE_PROTONAME,"City",&dbv))
{
- _tcsncpy (pstProf->City, dbv.ptszVal, sizeof(pstProf->City)/sizeof(TCHAR));
+ _tcsncpy_s(pstProf->City, dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
}
if(!db_get_s(NULL,SKYPE_PROTONAME,"OfficePhone",&dbv))
{
- strncpy (pstProf->OfficePhone, dbv.pszVal, sizeof(pstProf->OfficePhone));
+ strncpy_s(pstProf->OfficePhone, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
}
if(!db_get_s(NULL,SKYPE_PROTONAME,"HomePhone",&dbv))
{
- strncpy (pstProf->HomePhone, dbv.pszVal, sizeof(pstProf->HomePhone));
+ strncpy_s(pstProf->HomePhone, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
}
}
diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp index 362e1230ba..29f633bc45 100644 --- a/src/mir_core/langpack.cpp +++ b/src/mir_core/langpack.cpp @@ -364,7 +364,7 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start if (!lpinfo.tszLanguage[0] && (lpinfo.Locale == 0) || !GetLocaleInfo(lpinfo.Locale, LOCALE_SENGLANGUAGE, lpinfo.tszLanguage, sizeof(lpinfo.tszLanguage))) {
TCHAR *p = _tcschr(lpinfo.tszFileName, '_');
- mir_tstrncpy(lpinfo.tszLanguage, p != NULL ? p + 1 : lpinfo.tszFileName, sizeof(lpinfo.tszLanguage));
+ _tcsncpy_s(lpinfo.tszLanguage, ((p != NULL) ? (p + 1) : lpinfo.tszFileName), _TRUNCATE);
p = _tcsrchr(lpinfo.tszLanguage, _T('.'));
if (p != NULL) *p = '\0';
}
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp index 720f643acf..872bf4a033 100644 --- a/src/modules/chat/chat_opts.cpp +++ b/src/modules/chat/chat_opts.cpp @@ -141,12 +141,10 @@ void RegisterFonts(void) for (int i = 0; i < SIZEOF(fontOptionsList); i++, index++) {
FontOptionsList &FO = fontOptionsList[i];
- strncpy(fontid.dbSettingsGroup, CHATFONT_MODULE, sizeof(fontid.dbSettingsGroup));
+ strncpy_s(fontid.dbSettingsGroup, CHATFONT_MODULE, _TRUNCATE);
_tcsncpy_s(fontid.name, FO.szDescr, _TRUNCATE);
- char idstr[10];
- mir_snprintf(idstr, SIZEOF(idstr), "Font%d", index);
- strncpy(fontid.prefix, idstr, sizeof(fontid.prefix));
+ mir_snprintf(fontid.prefix, SIZEOF(fontid.prefix), "Font%d", index);
fontid.order = index;
switch (i) {
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp index 8cb1a16d47..3907f8f922 100644 --- a/src/modules/clist/clisttray.cpp +++ b/src/modules/clist/clisttray.cpp @@ -829,8 +829,8 @@ int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY* msn) nid.hWnd = cli.hwndContactList;
nid.uID = iconId;
nid.uFlags = NIF_INFO;
- mir_strncpy(nid.szInfo, msn->szInfo, sizeof(nid.szInfo));
- mir_strncpy(nid.szInfoTitle, msn->szInfoTitle, sizeof(nid.szInfoTitle));
+ strncpy_s(nid.szInfo, msn->szInfo, _TRUNCATE);
+ strncpy_s(nid.szInfoTitle, msn->szInfoTitle, _TRUNCATE);
nid.uTimeout = msn->uTimeout;
nid.dwInfoFlags = msn->dwInfoFlags;
return Shell_NotifyIconA(NIM_MODIFY, &nid) == 0;
|