[Ttssh2-commit] [4497] MS11-025 問題への対応

svnno****@sourc***** svnno****@sourc*****
2011年 6月 13日 (月) 17:33:31 JST


Revision: 4497
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4497
Author:   maya
Date:     2011-06-13 17:33:31 +0900 (Mon, 13 Jun 2011)

Log Message:
-----------
MS11-025 問題への対応

Modified Paths:
--------------
    trunk/teraterm/common/stdafx.cpp


-------------- next part --------------
Modified: trunk/teraterm/common/stdafx.cpp
===================================================================
--- trunk/teraterm/common/stdafx.cpp	2011-06-12 16:21:53 UTC (rev 4496)
+++ trunk/teraterm/common/stdafx.cpp	2011-06-13 08:33:31 UTC (rev 4497)
@@ -1,2 +1,47 @@
 #include "stdafx.h"
 
+
+// Visual Studio ‚ª MS11-025 “K—pÏ‚Ý‚Å MFC ‚ªƒXƒ^ƒeƒBƒbƒNƒŠƒ“ƒN‚̏ꍇ
+// http://club.pep.ne.jp/~hiroki.o/visualcpp/ms11-025_problem.htm
+// http://tedwvc.wordpress.com/2011/04/16/fixing-problems-with-findactctxsectionstring-in-mfc-security-updates/
+
+#undef FindActCtxSectionString
+#define FindActCtxSectionString MyFindActCtxSectionString
+
+#ifdef _UNICODE
+#define _FINDACTCTXSECTIONSTRING "FindActCtxSectionStringW"
+#else
+#define _FINDACTCTXSECTIONSTRING "FindActCtxSectionStringA"
+#endif
+
+typedef BOOL (WINAPI * PFN_FINDAC)(DWORD dwFlags, const GUID *lpExtensionGuid,ULONG ulSectionId,LPCTSTR lpStringToFind,PACTCTX_SECTION_KEYED_DATA ReturnedData);
+
+BOOL WINAPI MyFindActCtxSectionString(
+     DWORD dwFlags,
+     const GUID *lpExtensionGuid,
+     ULONG ulSectionId,
+     LPCTSTR lpStringToFind,
+     PACTCTX_SECTION_KEYED_DATA ReturnedData)
+{
+	// Bug #1 - Windows 2000
+	PFN_FINDAC pfnFindActCtxSectionString =NULL;
+	{
+		HINSTANCE hKernel32 = GetModuleHandle(_T("kernel32.dll"));
+		if (hKernel32 == NULL)
+		{
+			return FALSE;
+		}
+
+		pfnFindActCtxSectionString = (PFN_FINDAC) GetProcAddress(hKernel32, _FINDACTCTXSECTIONSTRING);
+
+		if (pfnFindActCtxSectionString == NULL)
+		{
+			/* pre-fusion OS, so no more checking.*/
+			return FALSE;
+		}
+	}
+
+	ReturnedData->cbSize = sizeof(ACTCTX_SECTION_KEYED_DATA); // Bug #2 - missing cbSize initializer
+	return pfnFindActCtxSectionString(/* dwFlags */ 0,  // Bug #3 memory leak - pass in zero as return handle not freed
+		lpExtensionGuid, ulSectionId, lpStringToFind, ReturnedData);
+}



Ttssh2-commit メーリングリストの案内