Predefined constants don't work in static expressions

General discussion on Zend Guard / Optimizer

Predefined constants don't work in static expressions

Postby mikh1250 on Tue Feb 14, 2017 9:20 pm


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

Posts: 1
Joined: Tue Feb 14, 2017 8:57 pm

Re: Predefined constants don't work in static expressions

Postby ioncube on 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.
Posts: 23
Joined: Fri Oct 23, 2009 4:14 pm

Return to Zend Guard / Optimizer

Who is online

Users browsing this forum: No registered users and 1 guest