dmitry Fri Jun 15 07:28:49 2007 UTC Modified files: /php-src/main main.c Log: Prevent crash in case of wrong arguments to CRT functions (dtrftime()) on PHP complead by MS VC8 http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.729&r2=1.730&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.729 php-src/main/main.c:1.730 --- php-src/main/main.c:1.729 Thu Jun 7 08:46:32 2007 +++ php-src/main/main.c Fri Jun 15 07:28:49 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.729 2007/06/07 08:46:32 tony2001 Exp $ */ +/* $Id: main.c,v 1.730 2007/06/15 07:28:49 dmitry Exp $ */ /* {{{ includes */ @@ -1763,6 +1763,36 @@ /* start additional PHP extensions */ php_register_extensions(&additional_modules, num_additional_modules TSRMLS_CC); +#if defined(PHP_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1400) +static _invalid_parameter_handler old_invalid_parameter_handler; + +void dummy_invalid_parameter_handler( + const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t pEwserved) +{ + static int called = 0; + char buf[1024]; + int len; + + if (!called) { + called = 1; + if (function) { + if (file) { + len = _snprintf(buf, sizeof(buf)-1, "Invalid parameter detected in CRT function '%ws' (%ws:%d)", function, file, line); + } else { + len = _snprintf(buf, sizeof(buf)-1, "Invalid parameter detected in CRT function '%ws'", function); + } + } else { + len = _snprintf(buf, sizeof(buf)-1, "Invalid CRT parameters detected"); + } + zend_error(E_WARNING, "%s", buf); + called = 0; + } +} +#endif /* load and startup extensions compiled as shared objects (aka DLLs) as requested by php.ini entries @@ -1872,6 +1902,12 @@ #else ts_free_id(core_globals_id); #endif + +#if defined(PHP_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1400) + if (old_invalid_parameter_handler == NULL) { + _set_invalid_parameter_handler(old_invalid_parameter_handler); + } +#endif } /* }}} */ @@ -1967,6 +2003,13 @@ fchdir(old_cwd_fd); close(old_cwd_fd); } +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + old_invalid_parameter_handler = + _set_invalid_parameter_handler(dummy_invalid_parameter_handler); + if (old_invalid_parameter_handler != NULL) { + _set_invalid_parameter_handler(old_invalid_parameter_handler); + } +#endif #else if (old_cwd[0] != '\0') { VCWD_CHDIR(old_cwd);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php