Predefined constants don't work in static expressions

General discussion on Zend Guard / Optimizer
Post Reply
mikh1250
Posts: 1
Joined: Tue Feb 14, 2017 8:57 pm

Predefined constants don't work in static expressions

Post by mikh1250 » Tue Feb 14, 2017 9:20 pm

Hello,

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

<?php
class Foo { public static $expr = __DIR__ . '-bar'; }
var_dump(Foo::$expr);
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

"\x00x00__DIR__sTr\x00\x00-bar"
Thanks

ioncube
Posts: 23
Joined: Fri Oct 23, 2009 4:14 pm

Re: Predefined constants don't work in static expressions

Post by ioncube » Mon Apr 03, 2017 4:27 pm

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.

Post Reply