XKeymacs for 64bit Windows
Revisão | 4f9498bc998fb84bf0a9da862e4828ae6bd1f668 (tree) |
---|---|
Hora | 2011-05-28 16:58:03 |
Autor | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Use secure versions of library functions.
@@ -64,24 +64,25 @@ void CDotXkeymacs::LoadMainData(LPCTSTR lpszFileName) | ||
64 | 64 | TCHAR szDir[_MAX_DIR] = {'\0'}; |
65 | 65 | |
66 | 66 | if (GetModuleFileName(NULL, szModuleFileName, sizeof(szModuleFileName))) { |
67 | - _tsplitpath(szModuleFileName, szDrive, szDir, NULL, NULL); | |
67 | + _tsplitpath_s(szModuleFileName, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0); | |
68 | 68 | } |
69 | 69 | |
70 | 70 | TCHAR szOldPath[MAX_PATH] = {'\0'}; // This path is used by XKeymacs 3.22 and earlier |
71 | - _tmakepath(szOldPath, szDrive, szDir, lpszFileName, m_szExt); | |
71 | + _tmakepath_s(szOldPath, szDrive, szDir, lpszFileName, m_szExt); | |
72 | 72 | |
73 | 73 | PathAppend(szDir, _T("etc")); |
74 | 74 | TCHAR szEtc[MAX_PATH] = {'\0'}; |
75 | - _tmakepath(szEtc, szDrive, szDir, NULL, NULL); | |
75 | + _tmakepath_s(szEtc, szDrive, szDir, NULL, NULL); | |
76 | 76 | (void)_tmkdir(szEtc); // make etc directory if needed |
77 | 77 | |
78 | 78 | TCHAR szPath[MAX_PATH] = {'\0'}; |
79 | - _tmakepath(szPath, szDrive, szDir, lpszFileName, m_szExt); | |
79 | + _tmakepath_s(szPath, szDrive, szDir, lpszFileName, m_szExt); | |
80 | 80 | |
81 | 81 | if (_trename(szOldPath, szPath)) { // try to move old file as backup when rename returns an error because files exist in both directorys |
82 | 82 | TCHAR szBackupPath[MAX_PATH] = {'\0'}; |
83 | 83 | TCHAR szBackupFlag[_MAX_FNAME] = _T("~"); |
84 | - _tmakepath(szBackupPath, szDrive, szDir, _tcscat(szBackupFlag, lpszFileName), m_szExt); | |
84 | + _tcscat_s(szBackupFlag, lpszFileName); | |
85 | + _tmakepath_s(szBackupPath, szDrive, szDir, szBackupFlag, m_szExt); | |
85 | 86 | (void)_trename(szOldPath, szBackupPath); // do nothing when a backup file has existed already |
86 | 87 | } |
87 | 88 |
@@ -92,7 +93,7 @@ void CDotXkeymacs::LoadUserData(LPCTSTR lpszFileName) | ||
92 | 93 | { |
93 | 94 | TCHAR szPath[MAX_PATH] = {'\0'}; |
94 | 95 | if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, TRUE)) { |
95 | - _tmakepath(szPath, NULL, szPath, lpszFileName, m_szExt); | |
96 | + _tmakepath_s(szPath, NULL, szPath, lpszFileName, m_szExt); | |
96 | 97 | Load(szPath); |
97 | 98 | } |
98 | 99 | } |
@@ -268,7 +269,10 @@ LPCTSTR CDotXkeymacs::GetLanguage() | ||
268 | 269 | LPCTSTR szLanguage = _T("unknown"); |
269 | 270 | |
270 | 271 | TCHAR lptstrFilename[MAX_PATH] = {'\0'}; |
271 | - _tmakepath(lptstrFilename, NULL, _tgetenv(_T("windir")), _T("explorer"), _T("exe")); | |
272 | + TCHAR windir[MAX_PATH] = ""; | |
273 | + size_t len; | |
274 | + _tgetenv_s(&len, windir, _T("windir")); | |
275 | + _tmakepath_s(lptstrFilename, NULL, windir, _T("explorer"), _T("exe")); | |
272 | 276 | DWORD dwLen = GetFileVersionInfoSize(lptstrFilename, NULL); |
273 | 277 | |
274 | 278 | if (dwLen) { |
@@ -589,14 +589,14 @@ void CMainFrame::OnHelpFinder() | ||
589 | 589 | { |
590 | 590 | TCHAR szPath[MAX_PATH] = {'\0'}; |
591 | 591 | const TCHAR szExt[] = _T("txt"); |
592 | - _tmakepath(szPath, NULL, NULL, CString(MAKEINTRESOURCE(IDS_README)), szExt); | |
592 | + _tmakepath_s(szPath, NULL, NULL, CString(MAKEINTRESOURCE(IDS_README)), szExt); | |
593 | 593 | |
594 | 594 | TCHAR szModuleFileName[MAX_PATH] = {'\0'}; |
595 | 595 | if (GetModuleFileName(NULL, szModuleFileName, sizeof(szModuleFileName))) { |
596 | 596 | TCHAR szDrive[_MAX_DRIVE] = {'\0'}; |
597 | 597 | TCHAR szDir[_MAX_DIR] = {'\0'}; |
598 | - _tsplitpath(szModuleFileName, szDrive, szDir, NULL, NULL); | |
599 | - _tmakepath(szPath, szDrive, szDir, CString(MAKEINTRESOURCE(IDS_README)), szExt); | |
598 | + _tsplitpath_s(szModuleFileName, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0); | |
599 | + _tmakepath_s(szPath, szDrive, szDir, CString(MAKEINTRESOURCE(IDS_README)), szExt); | |
600 | 600 | } |
601 | 601 | |
602 | 602 | ShellExecute(NULL, NULL, szPath, NULL, NULL, SW_SHOWNORMAL); |
@@ -408,7 +408,7 @@ BOOL CALLBACK CProfile::EnumWindowsProc(const HWND hWnd, const LPARAM lParam) | ||
408 | 408 | CComboBox *pApplication = (CComboBox*)lParam; |
409 | 409 | PTASK_LIST pTask = CProfile::m_TaskList; |
410 | 410 | |
411 | - TCHAR szWindowName[WINDOW_NAME_LENGTH]; | |
411 | + TCHAR szWindowName[WINDOW_TEXT_LENGTH]; | |
412 | 412 | TCHAR szClassName[CLASS_NAME_LENGTH]; |
413 | 413 | WINDOWPLACEMENT wpl; |
414 | 414 |
@@ -1787,9 +1787,10 @@ int CCommands::YankPop() | ||
1787 | 1787 | // M-!: cmd.exe/command.com |
1788 | 1788 | int CCommands::ShellCommand() |
1789 | 1789 | { |
1790 | - if (!CUtils::Run(_tgetenv(_T("XKEYMACS_SHELL")))) { | |
1791 | - CUtils::Run(_tgetenv(_T("COMSPEC"))); | |
1792 | - } | |
1790 | + TCHAR szShell[MAX_PATH]; | |
1791 | + size_t len; | |
1792 | + !_tgetenv_s(&len, szShell, _T("XKEYMACS_SHELL")) && len != 0 && CUtils::Run(szShell) || | |
1793 | + !_tgetenv_s(&len, szShell, _T("COMSPEC")) && len != 0 && CUtils::Run(szShell); | |
1793 | 1794 | return Reset(GOTO_HOOK); |
1794 | 1795 | } |
1795 | 1796 |
@@ -205,20 +205,20 @@ void CUtils::FairConsoleApplicationName(LPTSTR szApplicationName, LPTSTR szWindo | ||
205 | 205 | } |
206 | 206 | |
207 | 207 | if (*szWindowText == '"' && _tcschr(szWindowText+1, _T('"'))) { // "foo bar" -> foo bar |
208 | - int nApplicationName = _tcschr(szWindowText+1, _T('"')) - szWindowText - 1; // length of "foo bar" | |
209 | - _tcsncpy(szWindowText, szWindowText + 1, nApplicationName); | |
210 | - memset(szWindowText + nApplicationName, 0, WINDOW_TEXT_LENGTH - nApplicationName); | |
208 | + int len = _tcschr(szWindowText+1, _T('"')) - szWindowText - 1; // length of "foo bar" | |
209 | + memmove(szWindowText, szWindowText + 1, len); | |
210 | + memset(szWindowText + len, 0, WINDOW_TEXT_LENGTH - len); | |
211 | 211 | } else if (_tcschr(szWindowText, _T(' '))) { // foo bar -> foo |
212 | - LPTSTR pFirstSpace = _tcschr(szWindowText, _T(' ')); | |
213 | - memset(pFirstSpace, 0, WINDOW_TEXT_LENGTH - (pFirstSpace - szWindowText)); | |
212 | + LPTSTR p = _tcschr(szWindowText, _T(' ')); | |
213 | + memset(p, 0, WINDOW_TEXT_LENGTH - (p - szWindowText)); | |
214 | 214 | } |
215 | 215 | |
216 | 216 | memset(szApplicationName, 0, MAX_PATH); |
217 | - _stprintf(szApplicationName, _T("%s"), szWindowText); | |
217 | + _stprintf_s(szApplicationName, MAX_PATH, _T("%s"), szWindowText); | |
218 | 218 | |
219 | 219 | static LPCTSTR const szExe = _T(".exe"); |
220 | 220 | if (_tcsnicmp(szApplicationName + _tcslen(szApplicationName) - _tcslen(szExe), szExe, _tcslen(szExe))) { |
221 | - _tcscat(szApplicationName, szExe); | |
221 | + _tcscat_s(szApplicationName, MAX_PATH, szExe); | |
222 | 222 | } |
223 | 223 | } |
224 | 224 |
@@ -240,26 +240,26 @@ void CUtils::SetCorrectApplicationName(LPTSTR szApplicationName, LPTSTR szWindow | ||
240 | 240 | } |
241 | 241 | |
242 | 242 | TCHAR sz[WINDOW_TEXT_LENGTH] = {'\0'}; |
243 | - _stprintf(sz, _T("%s%s"), szPromptName[i], szSeparator); | |
243 | + _stprintf_s(sz, _T("%s%s"), szPromptName[i], szSeparator); | |
244 | 244 | |
245 | 245 | if (!_tcsnicmp(szWindowText, sz, _tcslen(sz))) { // "Command Promp - foo" |
246 | - _tcscpy(szWindowText, szWindowText + _tcslen(sz)); | |
246 | + _tcscpy_s(szWindowText, WINDOW_TEXT_LENGTH, szWindowText + _tcslen(sz)); | |
247 | 247 | FairConsoleApplicationName(szApplicationName, szWindowText); |
248 | 248 | return; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | for (i = 0; i < sizeof(szPromptPath) / sizeof(szPromptPath[0]); ++i) { |
253 | - TCHAR szWindowTextLower[WINDOW_TEXT_LENGTH] = {'\0'}; | |
254 | - _tcscpy(szWindowTextLower, szWindowText); | |
255 | - _tcslwr(szWindowTextLower); | |
253 | + TCHAR lower[WINDOW_TEXT_LENGTH] = {'\0'}; | |
254 | + _tcscpy_s(lower, szWindowText); | |
255 | + _tcslwr_s(lower); | |
256 | 256 | |
257 | - if (_tcsstr(szWindowTextLower, szPromptPath[i])) { | |
257 | + if (_tcsstr(lower, szPromptPath[i])) { | |
258 | 258 | TCHAR sz[WINDOW_TEXT_LENGTH] = {'\0'}; |
259 | - _stprintf(sz, _T("%s%s"), szPromptPath[i], szSeparator); | |
259 | + _stprintf_s(sz, _T("%s%s"), szPromptPath[i], szSeparator); | |
260 | 260 | |
261 | - if (_tcsstr(szWindowTextLower, sz)) { // "X:\WINNT\system32\cmd.exe - foo" | |
262 | - _tcscpy(szWindowText, _tcsstr(szWindowTextLower, sz) + _tcslen(sz)); | |
261 | + if (_tcsstr(lower, sz)) { // "X:\WINNT\system32\cmd.exe - foo" | |
262 | + _tcscpy_s(szWindowText, WINDOW_TEXT_LENGTH, _tcsstr(lower, sz) + _tcslen(sz)); | |
263 | 263 | FairConsoleApplicationName(szApplicationName, szWindowText); |
264 | 264 | return; |
265 | 265 | } else { // "X:\WINNT\system32\cmd.exe" |
@@ -269,7 +269,7 @@ void CUtils::SetCorrectApplicationName(LPTSTR szApplicationName, LPTSTR szWindow | ||
269 | 269 | } |
270 | 270 | |
271 | 271 | LPTSTR newName = NULL, newText = NULL; |
272 | - if (!_tcsicmp(szWindowText, _T("Cygwin Bash Shell")) | |
272 | + if (!_tcsicmp(szWindowText, _T("Cygwin Bash Shell")) | |
273 | 273 | || (*szWindowText == _T('~')) |
274 | 274 | || (*szWindowText == _T('/'))) { // Bash |
275 | 275 | newName = _T("bash.exe"); |
@@ -302,9 +302,9 @@ void CUtils::SetCorrectApplicationName(LPTSTR szApplicationName, LPTSTR szWindow | ||
302 | 302 | } |
303 | 303 | if (newName) { |
304 | 304 | memset(szApplicationName, 0, MAX_PATH); |
305 | - _stprintf(szApplicationName, newName); | |
305 | + _tcscpy_s(szApplicationName, MAX_PATH, newName); | |
306 | 306 | memset(szWindowText, 0, WINDOW_TEXT_LENGTH); |
307 | - _stprintf(szWindowText, newText); | |
307 | + _tcscpy_s(szWindowText, WINDOW_TEXT_LENGTH, newText); | |
308 | 308 | } |
309 | 309 | } else if (IsJavaW(szApplicationName)) { |
310 | 310 | LPTSTR newName = NULL; |
@@ -319,7 +319,7 @@ void CUtils::SetCorrectApplicationName(LPTSTR szApplicationName, LPTSTR szWindow | ||
319 | 319 | } |
320 | 320 | if (newName) { |
321 | 321 | memset(szApplicationName, 0, MAX_PATH); |
322 | - _stprintf(szApplicationName, newName); | |
322 | + _tcscpy_s(szApplicationName, MAX_PATH, newName); | |
323 | 323 | } |
324 | 324 | } |
325 | 325 | return; |
@@ -335,7 +335,7 @@ void CUtils::SetApplicationName(BOOL bImeComposition) | ||
335 | 335 | HKL hKL = GetKeyboardLayout(0); |
336 | 336 | if (ImmIsIME(hKL)) { |
337 | 337 | if (!ImmGetIMEFileName(hKL, m_szIMEName, sizeof(m_szIMEName))) { |
338 | - _tcsncpy(m_szIMEName, _T("IME"), sizeof(m_szIMEName)); // IDS_IME_FILE_NAME | |
338 | + _tcsncpy_s(m_szIMEName, _T("IME"), _TRUNCATE); // IDS_IME_FILE_NAME | |
339 | 339 | } |
340 | 340 | // CUtils::Log(_T("SetApplicationName: m_szIMEName == %s"), m_szIMEName); |
341 | 341 | } |
@@ -347,13 +347,13 @@ void CUtils::SetApplicationName(BOOL bImeComposition) | ||
347 | 347 | HKL hKL = GetKeyboardLayout(0); |
348 | 348 | if (ImmIsIME(hKL)) { |
349 | 349 | if (!ImmGetIMEFileName(hKL, m_szApplicationName, sizeof(m_szApplicationName))) { |
350 | - _tcsncpy(m_szApplicationName, m_szIMEName, sizeof(m_szApplicationName)); | |
350 | + _tcsncpy_s(m_szApplicationName, m_szIMEName, _TRUNCATE); | |
351 | 351 | } |
352 | - _tcsncpy(m_szIMEName, m_szApplicationName, sizeof(m_szIMEName)); | |
352 | + _tcsncpy_s(m_szIMEName, m_szApplicationName, sizeof(m_szIMEName)); | |
353 | 353 | } else { |
354 | 354 | // ImmIsIME return 0 on Word2002, Excel2002, etc. with IME2002, so... |
355 | 355 | // _tcsncpy(m_szApplicationName, _T("imjp81.ime"), sizeof(m_szApplicationName)); |
356 | - _tcsncpy(m_szApplicationName, m_szIMEName, sizeof(m_szApplicationName)); | |
356 | + _tcsncpy_s(m_szApplicationName, m_szIMEName, _TRUNCATE); | |
357 | 357 | } |
358 | 358 | } else { |
359 | 359 | // CUtils::Log(_T("SetApplicationName: appication (%s)"), m_szApplicationName); |
@@ -362,7 +362,7 @@ void CUtils::SetApplicationName(BOOL bImeComposition) | ||
362 | 362 | CString szFn(m_szApplicationName); |
363 | 363 | szFn.Delete(0, szFn.ReverseFind(_T('\\')) + 1); |
364 | 364 | ZeroMemory(m_szApplicationName, sizeof(m_szApplicationName)); |
365 | - _tcsncpy(m_szApplicationName, szFn, szFn.GetLength()); | |
365 | + _tcscpy_s(m_szApplicationName, szFn); | |
366 | 366 | |
367 | 367 | // CUtils::Log(_T("SetApplicationName: appication [%s]"), m_szApplicationName); |
368 | 368 |
@@ -370,7 +370,7 @@ void CUtils::SetApplicationName(BOOL bImeComposition) | ||
370 | 370 | // CUtils::Log(_T("SetApplicationName: console")); |
371 | 371 | |
372 | 372 | memset(m_szApplicationName, 0, sizeof(m_szApplicationName)); |
373 | - _tcscpy(m_szApplicationName, _T("CMD.exe")); | |
373 | + _tcscpy_s(m_szApplicationName, _T("CMD.exe")); | |
374 | 374 | TCHAR szWindowText[WINDOW_TEXT_LENGTH] = {'\0'}; |
375 | 375 | GetWindowText(GetForegroundWindow(), szWindowText, sizeof(szWindowText)); |
376 | 376 | SetCorrectApplicationName(m_szApplicationName, szWindowText); |
@@ -383,7 +383,7 @@ void CUtils::SetApplicationName(BOOL bImeComposition) | ||
383 | 383 | // CUtils::Log(_T("SetApplicationName: cygwin")); |
384 | 384 | |
385 | 385 | memset(m_szApplicationName, 0, sizeof(m_szApplicationName)); |
386 | - _tcscpy(m_szApplicationName, _T("bash.exe")); | |
386 | + _tcscpy_s(m_szApplicationName, _T("bash.exe")); | |
387 | 387 | } |
388 | 388 | // CUtils::Log(_T("name: %s"), m_szApplicationName); |
389 | 389 | } |
@@ -641,13 +641,13 @@ BOOL CUtils::IsConsole() | ||
641 | 641 | |
642 | 642 | BOOL CUtils::IsConsole(LPCTSTR szApplicationName) |
643 | 643 | { |
644 | - return !_tcsnicmp(szApplicationName, _T("WINOA386.MOD"), MAX_PATH) | |
645 | - || !_tcsnicmp(szApplicationName, _T("CMD.exe"), MAX_PATH); | |
644 | + return !_tcsicmp(szApplicationName, _T("WINOA386.MOD")) | |
645 | + || !_tcsicmp(szApplicationName, _T("CMD.exe")); | |
646 | 646 | } |
647 | 647 | |
648 | 648 | BOOL CUtils::IsJavaW(LPCTSTR szApplicationName) |
649 | 649 | { |
650 | - return !_tcsnicmp(szApplicationName, _T("javaw.exe"), MAX_PATH); | |
650 | + return !_tcsicmp(szApplicationName, _T("javaw.exe")); | |
651 | 651 | } |
652 | 652 | |
653 | 653 | BOOL CUtils::IsSleipnir() |
@@ -671,11 +671,12 @@ void CUtils::Log(LPTSTR fmt, ...) | ||
671 | 671 | |
672 | 672 | for (unsigned int nIndex = 0; nIndex < _tcslen(fmt); ) { |
673 | 673 | LPTSTR pNextString = fmt + nIndex; |
674 | - LPTSTR pLogEnd = szLog + _tcslen(szLog); | |
674 | + int len = _tcslen(szLog); | |
675 | + LPTSTR pLogEnd = szLog + len; | |
675 | 676 | |
676 | 677 | if (*pNextString == _T('%')) { |
677 | 678 | TCHAR szFormatTag[LOG_MAX] = {'0'}; |
678 | - _tcscpy(szFormatTag, pNextString); | |
679 | + _tcscpy_s(szFormatTag, pNextString); | |
679 | 680 | |
680 | 681 | switch (GetFormatTag(szFormatTag)) { |
681 | 682 | case _T('d'): |
@@ -685,36 +686,37 @@ void CUtils::Log(LPTSTR fmt, ...) | ||
685 | 686 | case _T('X'): |
686 | 687 | case _T('u'): |
687 | 688 | case _T('c'): |
688 | - _stprintf(pLogEnd, szFormatTag, va_arg(ap, int)); | |
689 | + _stprintf_s(pLogEnd, LOG_MAX - len, szFormatTag, va_arg(ap, int)); | |
689 | 690 | break; |
690 | 691 | case _T('s'): |
691 | - _stprintf(pLogEnd, szFormatTag, va_arg(ap, LPTSTR)); | |
692 | + _stprintf_s(pLogEnd, LOG_MAX - len, szFormatTag, va_arg(ap, LPTSTR)); | |
692 | 693 | break; |
693 | 694 | case _T('f'): |
694 | 695 | case _T('e'): |
695 | 696 | case _T('E'): |
696 | 697 | case _T('g'): |
697 | 698 | case _T('G'): |
698 | - _stprintf(pLogEnd, szFormatTag, va_arg(ap, double)); | |
699 | + _stprintf_s(pLogEnd, LOG_MAX - len, szFormatTag, va_arg(ap, double)); | |
699 | 700 | break; |
700 | 701 | case _T('p'): |
701 | - _stprintf(pLogEnd, szFormatTag, va_arg(ap, void *)); | |
702 | + _stprintf_s(pLogEnd, LOG_MAX - len, szFormatTag, va_arg(ap, void *)); | |
702 | 703 | break; |
703 | 704 | case _T('n'): |
704 | - _stprintf(pLogEnd, szFormatTag, va_arg(ap, int *)); | |
705 | + _stprintf_s(pLogEnd, LOG_MAX - len, szFormatTag, va_arg(ap, int *)); | |
705 | 706 | break; |
706 | 707 | case _T('%'): |
707 | 708 | default: |
708 | - _stprintf(pLogEnd, _T("%s"), szFormatTag); | |
709 | + _stprintf_s(pLogEnd, LOG_MAX - len, _T("%s"), szFormatTag); | |
709 | 710 | break; |
710 | 711 | } |
711 | 712 | |
712 | 713 | nIndex += _tcslen(szFormatTag); |
713 | 714 | } else { |
714 | 715 | TCHAR szString[LOG_MAX] = {'0'}; |
715 | - _tcscpy(szString, pNextString); | |
716 | - LPTSTR pString = _tcstok(szString, _T("%")); | |
717 | - _stprintf(pLogEnd, _T("%s"), pString); | |
716 | + _tcscpy_s(szString, pNextString); | |
717 | + LPTSTR c; | |
718 | + LPTSTR pString = _tcstok_s(szString, _T("%"), &c); | |
719 | + _stprintf_s(pLogEnd, LOG_MAX - len, _T("%s"), pString); | |
718 | 720 | |
719 | 721 | nIndex += _tcslen(pString); |
720 | 722 | } |
@@ -726,14 +728,15 @@ void CUtils::Log(LPTSTR fmt, ...) | ||
726 | 728 | TCHAR szPath[MAX_PATH] = {'\0'}; |
727 | 729 | if (GetTempPath(MAX_PATH, szPath)) { |
728 | 730 | #ifndef _WIN64 |
729 | - _tmakepath(szPath, NULL, szPath, _T("xkeylog"), _T("txt")); | |
731 | + _tmakepath_s(szPath, NULL, szPath, _T("xkeylog"), _T("txt")); | |
730 | 732 | #else |
731 | - _tmakepath(szPath, NULL, szPath, _T("xkeylog64"), _T("txt")); | |
733 | + _tmakepath_s(szPath, NULL, szPath, _T("xkeylog64"), _T("txt")); | |
732 | 734 | #endif |
733 | 735 | } else { |
734 | - _tcscpy(szPath, _T("c:\\xkeylog.txt")); | |
736 | + _tcscpy_s(szPath, _T("c:\\xkeylog.txt")); | |
735 | 737 | } |
736 | - FILE *fp = _tfopen(szPath, _T("a")); | |
738 | + FILE *fp; | |
739 | + _tfopen_s(&fp, szPath, _T("a")); | |
737 | 740 | _ftprintf(fp, _T("%8d: %s %s\n"), n++, m_szApplicationName, szLog); |
738 | 741 | fflush(fp); |
739 | 742 | fclose(fp); |
@@ -1238,14 +1238,14 @@ void CXkeymacsDll::SetModifierIcons() | ||
1238 | 1238 | |
1239 | 1239 | void CXkeymacsDll::SetApplicationName(int nApplicationID, CString szApplicationName) |
1240 | 1240 | { |
1241 | - ZeroMemory(m_Config.szSpecialApp[nApplicationID], sizeof(m_Config.szSpecialApp[nApplicationID])); | |
1242 | - _tcsncpy(m_Config.szSpecialApp[nApplicationID], szApplicationName, sizeof(m_Config.szSpecialApp[nApplicationID])); | |
1241 | + ZeroMemory(m_Config.szSpecialApp[nApplicationID], CLASS_NAME_LENGTH); | |
1242 | + _tcsncpy_s(m_Config.szSpecialApp[nApplicationID], szApplicationName, _TRUNCATE); | |
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | void CXkeymacsDll::SetWindowText(int nApplicationID, CString szWindowText) |
1246 | 1246 | { |
1247 | - ZeroMemory(m_Config.szWindowText[nApplicationID], sizeof(m_Config.szWindowText[nApplicationID])); | |
1248 | - _tcsncpy(m_Config.szWindowText[nApplicationID], szWindowText, sizeof(m_Config.szWindowText[nApplicationID])); | |
1247 | + ZeroMemory(m_Config.szWindowText[nApplicationID], WINDOW_TEXT_LENGTH); | |
1248 | + _tcsncpy_s(m_Config.szWindowText[nApplicationID], szWindowText, _TRUNCATE); | |
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | void CXkeymacsDll::SetCommandID(int nApplicationID, int nCommandType, int nKey, int nCommandID) |
@@ -1694,7 +1694,7 @@ void CXkeymacsDll::SetFunctionDefinition(int nFunctionID, CString szDefinition) | ||
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | memset(m_Config.szFunctionDefinition[nFunctionID], 0, sizeof(m_Config.szFunctionDefinition[nFunctionID])); |
1697 | - _stprintf(m_Config.szFunctionDefinition[nFunctionID], _T("%s"), szDefinition); | |
1697 | + _stprintf_s(m_Config.szFunctionDefinition[nFunctionID], _T("%s"), szDefinition); | |
1698 | 1698 | |
1699 | 1699 | return; |
1700 | 1700 |