msvcrt: check the inheritance block

André Hentschel nerv at dawncrow.de
Thu Aug 27 14:09:09 CDT 2009


Here i check the size of the "incoming" inheritance block, its size is defined as:
sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * MSVCRT_fdend;
So we really know its not our inheritance block if it has a size it could not have.

This comes without a testcase, as its logical by itself and a testcase is really hard for that.

---
 dlls/msvcrt/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 6671f2f..ae9318b 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -349,7 +349,7 @@ void msvcrt_init_io(void)
   InitializeCriticalSection(&MSVCRT_file_cs);
   MSVCRT_file_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": MSVCRT_file_cs");
   GetStartupInfoA(&si);
-  if (si.cbReserved2 != 0 && si.lpReserved2 != NULL)
+  if (si.cbReserved2 != 0 && (si.cbReserved2-sizeof(unsigned))%(sizeof(char) + sizeof(HANDLE))==0 && si.lpReserved2 != NULL)
   {
     char*       wxflag_ptr;
     HANDLE*     handle_ptr;
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list