php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64500 Impossible to disable Phar::interceptFileFuncs() behaviour
Submitted: 2013-03-24 07:21 UTC Modified: 2015-03-30 14:17 UTC
From: exbeinfo at gmail dot com Assigned:
Status: Not a bug Package: PHAR related
PHP Version: 5.4.13 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: exbeinfo at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-24 07:21 UTC] exbeinfo at gmail dot com
Description:
------------
Current implementation of Phar stub doesn't provide any way to disable impact of 
Phar::interceptFileFuncs().
If you tried to run the test script for text file in the same folder
php my.phar test.txt:
 File:test.txt
 Path:C:\projects\PrimordialCode\php\glitches\open stat issue\test.txt
 is_file:
 is_readable:
 file_exists:
 file_get_contents:I'm the test text.

The same execution for test.php:
php my.phar test.php

 File:test.php
 Path:C:\projects\PrimordialCode\php\glitches\open stat issue\test.php
 is_file:1
 is_readable:1
 file_exists:1
 file_get_contents:<?php

$file = isset($argv[1]) ? $argv[1] : null;
if(is_null($file)) exit('Please specify a file');
echo "\n File:" . $file;
echo "\n Path:" . realpath($file);
echo "\n is_file:" . is_file($file);
echo "\n is_readable:" . is_readable($file);
echo "\n file_exists:" . file_exists($file);
echo "\n file_get_contents:" . file_get_contents($file);



The issue caused by https://github.com/php/php-src/blob/master/ext/phar/stub.h
E.g. line with Phar::interceptFileFuncs() hardcoded call:
static const char newstub1_0[] = "';\n\nif (in_array('phar', 
stream_get_wrappers()) && class_exists('Phar', 0)) 
{\nPhar::interceptFileFuncs();\n .... 



Test script:
---------------
<?php // Script to build phar 
$phar = new Phar("my.phar",0, "my.phar");
$phar["test.php"] = file_get_contents("test.php");
$phar->setStub($phar->createDefaultStub("test.php"));

// Content of test.php
<?php
$file = isset($argv[1]) ? $argv[1] : null;
if(is_null($file)) exit('Please specify a file');
echo "\n File:" . $file;
echo "\n Path:" . realpath($file);
echo "\n is_file:" . is_file($file);
echo "\n is_readable:" . is_readable($file);
echo "\n file_exists:" . file_exists($file);
echo "\n file_get_contents:" . file_get_contents($file);


Expected result:
----------------
Provide a switch to disable/enabled the function call or phar header 
customization.

Actual result:
--------------
Unexpected behavior of file lookup 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-30 14:17 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2015-03-30 14:17 UTC] mike@php.net
One can set a custom stub.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 12:01:29 2025 UTC