Page 1 of 1

Predefined constants don't work in static expressions

PostPosted: Tue Feb 14, 2017 9:20 pm
by mikh1250

Static initialization expressions using predefined constants like __FILE__ and __DIR__ produce garbled results.
The bug occurrs with php 5.6 + zend guard 7 + debian 8 x64_86, but I think the version does not matter much.

To reproduce create a file - test.php
Code: Select all
class Foo { public static $expr = __DIR__ . '-bar'; }

Encode it with the cli tool:
Code: Select all
zendenc56 test.php test.enc.php

There should be no difference:
Code: Select all
diff -s <(php test.php) <(php test.enc.php)

yet, the php test.enc.php returns garbled string
Code: Select all


Re: Predefined constants don't work in static expressions

PostPosted: Mon Apr 03, 2017 4:27 pm
by ioncube
Interesting. Until we fixed it last November, our users had a similar problem when running PHP 5.6 files on PHP 5.6 and 7. Before 5.6 you could only have single value assignments in this context, but 5.6 added support for expressions, and extra handling was then needed to support the DIR/FILE pseudo constants within static expressions. Changes to PHP internals make producing systems for PHP code protection a challenge, but ultimately rewarding.