Ticket #221: local_files.diff
| File local_files.diff, 2.8 KB (added by thomasb, 4 years ago) |
|---|
-
xcache-1.2.2
old new 652 652 xc_entry_unholds_real(XG(var_holds), xc_var_caches, xc_var_hcache.size TSRMLS_CC); 653 653 } 654 654 /* }}} */ 655 static int xc_stat(const char *filename, const char *include_path, struct stat *pbuf TSRMLS_DC) /* {{{ */655 static int xc_stat(const char *filename, const char *include_path, char *full_path, struct stat *pbuf TSRMLS_DC) /* {{{ */ 656 656 { 657 657 char filepath[MAXPATHLEN]; 658 658 char *paths, *path; … … 660 660 int size = strlen(include_path) + 1; 661 661 char tokens[] = { DEFAULT_DIR_SEPARATOR, '\0' }; 662 662 663 paths = (char *)do_alloca(size); 664 memcpy(paths, include_path, size); 663 if (zend_is_executing(TSRMLS_C)) { 664 char *exec_fname = zend_get_executed_filename(TSRMLS_C); 665 int exec_fname_length = strlen(exec_fname); 666 int path_length = strlen(include_path); 667 668 while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); 669 if ((exec_fname && exec_fname[0] == '[') 670 || exec_fname_length<=0) { 671 /* [no active file] or no path */ 672 paths = (char *)do_alloca(size); 673 memcpy(paths, include_path, size); 674 } else { 675 paths = (char *) do_alloca(exec_fname_length + path_length +1 +1); 676 memcpy(paths, include_path, path_length); 677 paths[path_length] = DEFAULT_DIR_SEPARATOR; 678 memcpy(paths+path_length+1, exec_fname, exec_fname_length); 679 paths[path_length + exec_fname_length +1] = '\0'; 680 } 681 } else { 682 paths = (char *)do_alloca(size); 683 memcpy(paths, include_path, size); 684 } 665 685 666 686 for (path = php_strtok_r(paths, tokens, &tokbuf); path; path = php_strtok_r(NULL, tokens, &tokbuf)) { 667 687 if (snprintf(filepath, sizeof(filepath), "%s/%s", path, filename) >= MAXPATHLEN - 1) { 668 688 continue; 669 689 } 670 690 if (VCWD_STAT(filepath, pbuf) == 0) { 691 if (full_path) { 692 memcpy(full_path, filepath, strlen(filepath) + 1); 693 } 671 694 free_alloca(paths); 672 695 return 0; 673 696 } … … 719 742 xc_entry_data_php_t *php; 720 743 char *ptr; 721 744 time_t delta; 745 char real_name_buffer[MAXPATHLEN]; 746 int real_name = 0; 722 747 723 748 if (!filename || !SG(request_info).path_translated) { 724 749 return 0; … … 762 787 not_relative_path: 763 788 764 789 /* use include_path */ 765 if (xc_stat(filename, PG(include_path), pbuf TSRMLS_CC) != 0) {790 if (xc_stat(filename, PG(include_path), real_name_buffer, pbuf TSRMLS_CC) != 0) { 766 791 return 0; 767 792 } 793 real_name = 1; 768 794 769 795 /* fall */ 770 796 … … 795 821 #endif 796 822 { 797 823 /* hash on filename, let's expand it to real path */ 798 filename = expand_filepath(filename, opened_path_buffer TSRMLS_CC); 824 if (!real_name) { 825 filename = expand_filepath(filename, opened_path_buffer TSRMLS_CC); 826 } else { 827 filename = expand_filepath(real_name_buffer, opened_path_buffer TSRMLS_CC); 828 } 829 799 830 if (filename == NULL) { 800 831 return 0; 801 832 }

