]> granicus.if.org Git - php/commitdiff
- Fixed a possible stack exaustion inside fnmatch(). Reporeted by Stefan Esser
authorIlia Alshanetsky <iliaa@php.net>
Sun, 2 May 2010 19:34:21 +0000 (19:34 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 2 May 2010 19:34:21 +0000 (19:34 +0000)
NEWS
ext/standard/file.c

diff --git a/NEWS b/NEWS
index 50c70a4b884fd6b12da3696ebbdb45d9071ad5bc..126644650a7e6d40cdf7b6692b2252a220246725 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ PHP                                                                        NEWS
 - Fixed very rare memory leak in mysqlnd, when binding thousands of columns.
   (Andrey)
 
+- Fixed a possible stack exaustion inside fnmatch(). Reporeted by Stefan    
+  Esser (Ilia)
 - Fixed a possible dechunking filter buffer overflow. Reported by Stefan Esser.
   (Pierre)
 - Fixed a possible arbitrary memory access inside sqlite extension. Reported 
index 704ef1231fb7e7e16f48012a6e2dab3383c8386a..0c53689582d0b7a7374868adc35bd83ed04a9217 100644 (file)
@@ -136,26 +136,12 @@ php_file_globals file_globals;
 
 /* {{{ ZTS-stuff / Globals / Prototypes */
 
-/* sharing globals is *evil* */
-static int le_stream_context = FAILURE;
 
-PHPAPI int php_le_stream_context(void)
-{
-       return le_stream_context;
-}
 /* }}} */
 
 /* {{{ Module-Stuff
 */
-static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
-{
-       php_stream_context *context = (php_stream_context*)rsrc->ptr;
-       if (context->options) {
-               zval_ptr_dtor(&context->options);
-               context->options = NULL;
-       }
-       php_stream_context_free(context);
-}
+
 
 static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
 {
@@ -176,7 +162,6 @@ PHP_INI_END()
 
 PHP_MINIT_FUNCTION(file)
 {
-       le_stream_context = zend_register_list_destructors_ex(file_context_dtor, NULL, "stream-context", module_number);
 
 #ifdef ZTS
        ts_allocate_id(&file_globals_id, sizeof(php_file_globals), (ts_allocate_ctor) file_globals_ctor, (ts_allocate_dtor) file_globals_dtor);
@@ -2521,6 +2506,10 @@ PHP_FUNCTION(fnmatch)
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename exceeds the maximum allowed length of %d characters", MAXPATHLEN);
                RETURN_FALSE;
        }
+       if (pattern_len >= MAXPATHLEN) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
+               RETURN_FALSE;
+       }
 
        RETURN_BOOL( ! fnmatch( pattern, filename, flags ));
 }