php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #49625
Patch php_sql_autoload_mixed_case_fix revision 2012-06-15 20:00 UTC by jdornan at stanford dot edu

Patch php_sql_autoload_mixed_case_fix for SPL related Bug #49625

Patch version 2012-06-15 20:00 UTC

Return to Bug #49625 | Download this patch
Patch Revisions:

Developer: jdornan@stanford.edu

*** php_spl.c	2012-06-15 15:51:29.000000000 -0400
--- php_spl.c.orig	2012-06-15 15:12:28.000000000 -0400
***************
*** 222,239 ****
  static int spl_autoload(const char *class_name, const char * lc_name, int class_name_len, const char * file_extension TSRMLS_DC) /* {{{ */
  {
  	char *class_file;
- 	char *lc_class_file;
  	int class_file_len;
- 	int lc_class_file_len;
  	int dummy = 1;
- 	int mixed_case = 0;
  	zend_file_handle file_handle;
  	zend_op_array *new_op_array;
  	zval *result = NULL;
  	int ret;
  
! 	lc_class_file_len = spprintf(&lc_class_file, 0, "%s%s", lc_name, file_extension);
! 	class_file_len = spprintf(&class_file, 0, "%s%s", class_name, file_extension);
  
  #if DEFAULT_SLASH != '\\'
  	{
--- 222,235 ----
  static int spl_autoload(const char *class_name, const char * lc_name, int class_name_len, const char * file_extension TSRMLS_DC) /* {{{ */
  {
  	char *class_file;
  	int class_file_len;
  	int dummy = 1;
  	zend_file_handle file_handle;
  	zend_op_array *new_op_array;
  	zval *result = NULL;
  	int ret;
  
! 	class_file_len = spprintf(&class_file, 0, "%s%s", lc_name, file_extension);
  
  #if DEFAULT_SLASH != '\\'
  	{
***************
*** 249,267 ****
  	ret = php_stream_open_for_zend_ex(class_file, &file_handle, ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
  
  	if (ret == SUCCESS) {
! 		mixed_case = 1;
! 	}
! 
!         /* fall back to lowercase file name. should issue deprecated warning. */
!         if (ret != SUCCESS) {
! 		ret = php_stream_open_for_zend_ex(lc_class_file, &file_handle, ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
!         }
! 
! 	if (ret == SUCCESS) {
! 		if (!file_handle.opened_path && mixed_case == 1) {
  			file_handle.opened_path = estrndup(class_file, class_file_len);
- 		} else if(!file_handle.opened_path && mixed_case == 0) {
- 			file_handle.opened_path = estrndup(lc_class_file, lc_class_file_len);
  		}
  		if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) {
  			new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
--- 245,252 ----
  	ret = php_stream_open_for_zend_ex(class_file, &file_handle, ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
  
  	if (ret == SUCCESS) {
! 		if (!file_handle.opened_path) {
  			file_handle.opened_path = estrndup(class_file, class_file_len);
  		}
  		if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) {
  			new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
***************
*** 287,298 ****
  				}
  			}
  
- 			efree(lc_class_file);
  			efree(class_file);
  			return zend_hash_exists(EG(class_table), (char*)lc_name, class_name_len+1);
  		}
  	}
- 	efree(lc_class_file);
  	efree(class_file);
  	return 0;
  } /* }}} */
--- 272,281 ----
***************
*** 328,334 ****
  			found = 1;
  			break; /* loaded */
  		}
- 
  		pos1 = pos2 ? pos2 + 1 : NULL;
  	}
  	efree(lc_name);
--- 311,316 ----
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Dec 04 02:05:53 2022 UTC