[ttssh2-commit] [9550] wcscpy(),wcscat() を _s系に置き換え

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 12月 1日 (水) 00:58:52 JST


Revision: 9550
          https://osdn.net/projects/ttssh2/scm/svn/commits/9550
Author:   zmatsuo
Date:     2021-12-01 00:58:52 +0900 (Wed, 01 Dec 2021)
Log Message:
-----------
wcscpy(),wcscat() を _s系に置き換え

- warning C4996: 'wcscpy': This function or variable may be unsafe.
- remove static wcscpy_s()  implement

Modified Paths:
--------------
    trunk/teraterm/common/dlglib_tmpl.cpp
    trunk/teraterm/common/ttlib_static_cpp.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/dlglib_tmpl.cpp
===================================================================
--- trunk/teraterm/common/dlglib_tmpl.cpp	2021-11-30 15:58:43 UTC (rev 9549)
+++ trunk/teraterm/common/dlglib_tmpl.cpp	2021-11-30 15:58:52 UTC (rev 9550)
@@ -85,17 +85,6 @@
 } DLGITEMTEMPLATEEX;
 #pragma pack(pop)
 
-#if 0 // !defined(_MSC_VER)
-static inline errno_t wcscpy_s(
-	wchar_t *dest,
-	size_t dest_size,
-	const wchar_t *src)
-{
-	wcscpy(dest, src);
-	return 0;
-}
-#endif
-
 static size_t CopySz(const WORD *src, WORD *dest)
 {
 	size_t size = 0;

Modified: trunk/teraterm/common/ttlib_static_cpp.cpp
===================================================================
--- trunk/teraterm/common/ttlib_static_cpp.cpp	2021-11-30 15:58:43 UTC (rev 9549)
+++ trunk/teraterm/common/ttlib_static_cpp.cpp	2021-11-30 15:58:52 UTC (rev 9550)
@@ -950,9 +950,9 @@
 	wchar_t *fullpath;
 	size_t size = wcslen(HomeDir) + 1 + wcslen(UILanguageFileRel) + 1;
 	wchar_t *rel = (wchar_t *)malloc(sizeof(wchar_t) * size);
-	wcscpy(rel, HomeDir);
-	wcscat(rel, L"\\");
-	wcscat(rel, UILanguageFileRel);
+	wcscpy_s(rel, size, HomeDir);
+	wcscat_s(rel, size, L"\\");
+	wcscat_s(rel, size, UILanguageFileRel);
 	hGetFullPathNameW(rel, &fullpath, NULL);
 	free(rel);
 	return fullpath;
@@ -983,7 +983,7 @@
 		// My Documents \x82\xC9 file \x82\xAA\x82\xA0\x82邩?
 		size_t destlen = (wcslen(MyDoc) + wcslen(file) + 1 + 1) * sizeof(wchar_t);
 		wchar_t *dest = (wchar_t *)malloc(sizeof(wchar_t) * destlen);
-		wcscpy(dest, MyDoc);
+		wcscpy_s(dest, destlen, MyDoc);
 		AppendSlashW(dest,destlen);
 		wcsncat_s(dest, destlen, file, _TRUNCATE);
 		DWORD r = GetFileAttributesW(dest);
@@ -1000,7 +1000,7 @@
 
 	size_t destlen = (wcslen(home) + wcslen(file) + 1 + 1) * sizeof(wchar_t);
 	wchar_t *dest = (wchar_t *)malloc(sizeof(wchar_t) * destlen);
-	wcscpy(dest, home);
+	wcscpy_s(dest, destlen, home);
 	AppendSlashW(dest,destlen);
 	wcsncat_s(dest, destlen, file, _TRUNCATE);
 	return dest;


ttssh2-commit メーリングリストの案内
Back to archive index