php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #64063
Patch Fix-includes-relative-path-search revision 2013-01-24 14:10 UTC by iliya at polihronov dot com

Patch Fix-includes-relative-path-search for APC Bug #64063

Patch version 2013-01-24 14:10 UTC

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

Developer: iliya@polihronov.com

diff -Naur APC-3.1.14.orig//apc.c APC-3.1.14//apc.c
--- APC-3.1.14.orig//apc.c	2013-01-03 02:11:59.000000000 +0000
+++ APC-3.1.14//apc.c	2013-01-24 13:13:48.000000000 +0000
@@ -309,10 +309,10 @@
       ((len) >= 4 && strncmp((fname), "ogg:", 4) == 0)  || \
       ((len) >= 7 && strncmp((fname), "expect:", 7) == 0))
 
-int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC)
+int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo,
+       const char *exec_fname TSRMLS_DC)
 {
     char** paths = NULL;
-    const char *exec_fname;
     int exec_fname_length;
     int found = 0;
     int i;
@@ -414,7 +414,8 @@
     /* check in path of the calling scripts' current working directory */
     /* modified from main/streams/plain_wrapper.c */
     if(!found && zend_is_executing(TSRMLS_C)) {
-        exec_fname = zend_get_executed_filename(TSRMLS_C);
+   if (!exec_fname)
+       exec_fname = zend_get_executed_filename(TSRMLS_C);
         exec_fname_length = strlen(exec_fname);
         while((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length]));
         if((exec_fname && exec_fname[0] != '[') && exec_fname_length > 0) {
diff -Naur APC-3.1.14.orig//apc.h APC-3.1.14//apc.h
--- APC-3.1.14.orig//apc.h	2013-01-03 02:11:59.000000000 +0000
+++ APC-3.1.14//apc.h	2013-01-24 13:13:48.000000000 +0000
@@ -93,7 +93,8 @@
     php_stream_statbuf st_buf;
 } apc_fileinfo_t;
 
-extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC);
+extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo,
+       const char *exec_fname TSRMLS_DC);
 
 /* regular expression wrapper functions */
 extern void* apc_regex_compile_array(char* patterns[] TSRMLS_DC);
diff -Naur APC-3.1.14.orig//apc_cache.c APC-3.1.14//apc_cache.c
--- APC-3.1.14.orig//apc_cache.c	2013-01-03 02:11:59.000000000 +0000
+++ APC-3.1.14//apc_cache.c	2013-01-24 13:13:48.000000000 +0000
@@ -960,7 +960,7 @@
 
             fileinfo = apc_php_malloc(sizeof(apc_fileinfo_t) TSRMLS_CC);
 
-            if (apc_search_paths(filename, include_path, fileinfo TSRMLS_CC) != 0) {
+            if (apc_search_paths(filename, include_path, fileinfo, NULL TSRMLS_CC) != 0) {
                 apc_warning("apc failed to locate %s - bailing" TSRMLS_CC, filename);
                 goto cleanup;
             }
@@ -991,7 +991,7 @@
     if(tmp_buf) {
         fileinfo->st_buf.sb = *tmp_buf;
     } else {
-        if (apc_search_paths(filename, include_path, fileinfo TSRMLS_CC) != 0) {
+        if (apc_search_paths(filename, include_path, fileinfo, NULL TSRMLS_CC) != 0) {
             apc_debug("Stat failed %s - bailing (%s) (%d)\n" TSRMLS_CC, filename,SG(request_info).path_translated);
             goto cleanup;
         }
diff -Naur APC-3.1.14.orig//apc_compile.c APC-3.1.14//apc_compile.c
--- APC-3.1.14.orig//apc_compile.c	2013-01-03 02:11:59.000000000 +0000
+++ APC-3.1.14//apc_compile.c	2013-01-24 13:14:42.000000000 +0000
@@ -1367,13 +1367,13 @@
                 (zo->op1_type == IS_CONST && Z_TYPE_P(zo->op1.zv) == IS_STRING)) {
                 /* constant includes */
                 if(!IS_ABSOLUTE_PATH(Z_STRVAL_P(zo->op1.zv),Z_STRLEN_P(zo->op1.zv))) { 
-                    if (apc_search_paths(Z_STRVAL_P(zo->op1.zv), PG(include_path), fileinfo TSRMLS_CC) == 0) {
+                    if (apc_search_paths(Z_STRVAL_P(zo->op1.zv), PG(include_path), fileinfo, src->filename TSRMLS_CC) == 0) {
 #else
             if((zo->opcode == ZEND_INCLUDE_OR_EVAL) && 
                 (zo->op1.op_type == IS_CONST && zo->op1.u.constant.type == IS_STRING)) {
                 /* constant includes */
                 if(!IS_ABSOLUTE_PATH(Z_STRVAL_P(&zo->op1.u.constant),Z_STRLEN_P(&zo->op1.u.constant))) { 
-                    if (apc_search_paths(Z_STRVAL_P(&zo->op1.u.constant), PG(include_path), fileinfo TSRMLS_CC) == 0) {
+                    if (apc_search_paths(Z_STRVAL_P(&zo->op1.u.constant), PG(include_path), fileinfo, src->filename TSRMLS_CC) == 0) {
 #endif
                         if((fullpath = realpath(fileinfo->fullpath, canon_path))) {
                             /* everything has to go through a realpath() */
diff -Naur APC-3.1.14.orig//apc_main.c APC-3.1.14//apc_main.c
--- APC-3.1.14.orig//apc_main.c	2013-01-03 02:11:59.000000000 +0000
+++ APC-3.1.14//apc_main.c	2013-01-24 13:15:10.000000000 +0000
@@ -663,7 +663,7 @@
         if(tmp_buf) {
             fileinfo.st_buf.sb = *tmp_buf;
         } else {
-            if (apc_search_paths(h->filename, PG(include_path), &fileinfo TSRMLS_CC) != 0) {
+            if (apc_search_paths(h->filename, PG(include_path), &fileinfo, NULL TSRMLS_CC) != 0) {
                 apc_debug("Stat failed %s - bailing (%s) (%d)\n" TSRMLS_CC,h->filename,SG(request_info).path_translated);
                 return old_compile_file(h, type TSRMLS_CC);
             }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC