On 19/08/2010 11:57, Bram Moolenaar wrote:

Mike Williams wrote:

On 18/08/2010 18:54, Sergey Khorev wrote:
It is by design in the recent VC CRT libraries (VS2005 onwards?) Any
unsupported format specifier will result in a crash. On Windows, or at
least builds that use recent VC CRT libraries, VIM needs to validate the
format string that it only contains supported format specifiers. I'm
guessing mingw is using older versions of the Windows CRT or has its own
version.

Attached is a patch to check for allowed specifiers for Windows.  Not sure
if any other platforms need a similar check (I doubt it).  Don't know if
need extra code to cope with multi-byte format strings.  Don't know if
having the check function in eval.c is the right thing to do. Does stop the
crash for me.

Perhaps another options would be installation of custom validation
handler via _set_invalid_parameter_handler as described on
http://msdn.microsoft.com/en-us/library/ksazx244(v=VS.80).aspx

Unfortunately I cannot provide a patch at the moment. Maybe later if
no one outruns me.

F1rst!  :-)

Pros: All Windows specific code.
Cons: Can't do anything clever with an invalid format string.

Should be ok with mingw32.

Should we reset the bad_param_handler after invoking strftime()?

I see no benefit in doing this. The function has no function other than preventing a hard crash by the CRT. Other CRT functions may provoke a crash with invalid parameters. It adds complexity in having to have mch_handler_on/off() around the call to strftime(). What do you feel we miss/gain by resetting the handler?

We should at least give an error message in the handler.  And set
a flag that it failed.

Failure of strftime is indicated by it returning a length of 0 (assuming the format string is not zero length) as well as setting errno. What would having yet another flag (in Windows only builds) achieve? Note that running in a debug build will cause warning dialogs to appear with invalid parameters so you haven't lost a means of automatically having the problem flagged! How many people actually run a debug build of VIM to pick up these additional checks and warnings? (I must admit I don't).

TTFN

Mike
--
Adversity makes men, and prosperity makes monsters.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui