Patch for php_if_getlastmod Seg-fault

From: Date: Mon, 28 Feb 2000 12:51:19 +0000
Subject: Patch for php_if_getlastmod Seg-fault
Groups: php.version4 
Request: Send a blank email to php-version4+get-11115@lists.php.net to get a copy of this message
Hi, Attached is a patch for the segfaults that I keep getting in calls to php_if_getlastmod. The problem occurs in ext/standard/pageinfo.c, line 47, when 'pstat' is assigned the value NULL by the function sapi_get_stat(). That function (from SAPI.c), in turn, returns NULL if the following condition is true: if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &SG(global_stat))==-1)) The 'stat' fails b/c of a file not found error. Using the cgi version from the command line, I noticed that sapi_globlas->path_translated is a relative link. This would work except that somehow php changes directories to the directory of the script. For example, if I am in /www/phpinc, and execute php ../html/test/index.php, then when the above line is executed the working directory is /www/html/test, but path_translated is still ../html/test/index.php. It seems to me that the easiest solution is to have "path_translated" always be an absolute path, or not to change directories :-). The patch, which does not provide the correct info but at least stops the seg-faults, is: --- ext/standard/pageinfo.c.orig Mon Feb 28 07:35:37 2000 +++ ext/standard/pageinfo.c Mon Feb 28 07:35:58 2000 @@ -46,7 +46,7 @@ pstat = sapi_get_stat(); - if (BG(page_uid)==-1) { + if ((BG(page_uid)==-1) && pstat) { BG(page_uid) = pstat->st_uid; BG(page_inode) = pstat->st_ino; BG(page_mtime) = pstat->st_mtime;

« previous php.version4 (#11115) next »