Karsten Hopp a8d449
To: vim-dev@vim.org
Karsten Hopp a8d449
Subject: Patch 7.3.009
Karsten Hopp a8d449
Fcc: outbox
Karsten Hopp a8d449
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp a8d449
Mime-Version: 1.0
Karsten Hopp a8d449
Content-Type: text/plain; charset=UTF-8
Karsten Hopp a8d449
Content-Transfer-Encoding: 8bit
Karsten Hopp a8d449
------------
Karsten Hopp a8d449
Karsten Hopp a8d449
Patch 7.3.009
Karsten Hopp a8d449
Problem:    Win32: Crash on Windows when using a bad argument for strftime().
Karsten Hopp a8d449
	    (Christian Brabandt)
Karsten Hopp a8d449
Solution:   Use the bad_param_handler(). (Mike Williams)
Karsten Hopp a8d449
Files:	    src/os_win32.c
Karsten Hopp a8d449
Karsten Hopp a8d449
Karsten Hopp a8d449
*** ../vim-7.3.008/src/os_win32.c	2010-08-15 21:57:27.000000000 +0200
Karsten Hopp a8d449
--- src/os_win32.c	2010-09-21 17:02:54.000000000 +0200
Karsten Hopp a8d449
***************
Karsten Hopp a8d449
*** 1615,1620 ****
Karsten Hopp a8d449
--- 1615,1649 ----
Karsten Hopp a8d449
      return TRUE;
Karsten Hopp a8d449
  }
Karsten Hopp a8d449
  
Karsten Hopp a8d449
+ #if ((defined(__MINGW32__) || defined (__CYGWIN32__)) && \
Karsten Hopp a8d449
+         __MSVCRT_VERSION__ >= 0x800) || (defined(_MSC_VER) && _MSC_VER >= 1400)
Karsten Hopp a8d449
+ /*
Karsten Hopp a8d449
+  * Bad parameter handler.
Karsten Hopp a8d449
+  *
Karsten Hopp a8d449
+  * Certain MS CRT functions will intentionally crash when passed invalid
Karsten Hopp a8d449
+  * parameters to highlight possible security holes.  Setting this function as
Karsten Hopp a8d449
+  * the bad parameter handler will prevent the crash.
Karsten Hopp a8d449
+  *
Karsten Hopp a8d449
+  * In debug builds the parameters contain CRT information that might help track
Karsten Hopp a8d449
+  * down the source of a problem, but in non-debug builds the arguments are all
Karsten Hopp a8d449
+  * NULL/0.  Debug builds will also produce assert dialogs from the CRT, it is
Karsten Hopp a8d449
+  * worth allowing these to make debugging of issues easier.
Karsten Hopp a8d449
+  */
Karsten Hopp a8d449
+     static void
Karsten Hopp a8d449
+ bad_param_handler(const wchar_t *expression,
Karsten Hopp a8d449
+     const wchar_t *function,
Karsten Hopp a8d449
+     const wchar_t *file,
Karsten Hopp a8d449
+     unsigned int line,
Karsten Hopp a8d449
+     uintptr_t pReserved)
Karsten Hopp a8d449
+ {
Karsten Hopp a8d449
+ }
Karsten Hopp a8d449
+ 
Karsten Hopp a8d449
+ # define SET_INVALID_PARAM_HANDLER \
Karsten Hopp a8d449
+ 	((void)_set_invalid_parameter_handler(bad_param_handler))
Karsten Hopp a8d449
+ #else
Karsten Hopp a8d449
+ # define SET_INVALID_PARAM_HANDLER
Karsten Hopp a8d449
+ #endif
Karsten Hopp a8d449
+ 
Karsten Hopp a8d449
  #ifdef FEAT_GUI_W32
Karsten Hopp a8d449
  
Karsten Hopp a8d449
  /*
Karsten Hopp a8d449
***************
Karsten Hopp a8d449
*** 1627,1632 ****
Karsten Hopp a8d449
--- 1656,1664 ----
Karsten Hopp a8d449
      extern int _fmode;
Karsten Hopp a8d449
  #endif
Karsten Hopp a8d449
  
Karsten Hopp a8d449
+     /* Silently handle invalid parameters to CRT functions */
Karsten Hopp a8d449
+     SET_INVALID_PARAM_HANDLER;
Karsten Hopp a8d449
+ 
Karsten Hopp a8d449
      /* Let critical errors result in a failure, not in a dialog box.  Required
Karsten Hopp a8d449
       * for the timestamp test to work on removed floppies. */
Karsten Hopp a8d449
      SetErrorMode(SEM_FAILCRITICALERRORS);
Karsten Hopp a8d449
***************
Karsten Hopp a8d449
*** 2103,2108 ****
Karsten Hopp a8d449
--- 2135,2143 ----
Karsten Hopp a8d449
      extern int _fmode;
Karsten Hopp a8d449
  #endif
Karsten Hopp a8d449
  
Karsten Hopp a8d449
+     /* Silently handle invalid parameters to CRT functions */
Karsten Hopp a8d449
+     SET_INVALID_PARAM_HANDLER;
Karsten Hopp a8d449
+ 
Karsten Hopp a8d449
      /* Let critical errors result in a failure, not in a dialog box.  Required
Karsten Hopp a8d449
       * for the timestamp test to work on removed floppies. */
Karsten Hopp a8d449
      SetErrorMode(SEM_FAILCRITICALERRORS);
Karsten Hopp a8d449
*** ../vim-7.3.008/src/version.c	2010-09-21 16:56:29.000000000 +0200
Karsten Hopp a8d449
--- src/version.c	2010-09-21 17:27:36.000000000 +0200
Karsten Hopp a8d449
***************
Karsten Hopp a8d449
*** 716,717 ****
Karsten Hopp a8d449
--- 716,719 ----
Karsten Hopp a8d449
  {   /* Add new patch number below this line */
Karsten Hopp a8d449
+ /**/
Karsten Hopp a8d449
+     9,
Karsten Hopp a8d449
  /**/
Karsten Hopp a8d449
Karsten Hopp a8d449
-- 
Karsten Hopp a8d449
Wizards had always known that the act of observation changed the thing that
Karsten Hopp a8d449
was observed, and sometimes forgot that it also changed the observer too.
Karsten Hopp a8d449
			Terry Pratchett  -  Interesting times
Karsten Hopp a8d449
Karsten Hopp a8d449
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp a8d449
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp a8d449
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp a8d449
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///