Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpd on 32bit via negative result of unpack #15

Closed
emanuelb opened this issue May 18, 2017 · 1 comment
Closed

fpd on 32bit via negative result of unpack #15

emanuelb opened this issue May 18, 2017 · 1 comment
Assignees
Labels
bug

Comments

@emanuelb
Copy link

@emanuelb emanuelb commented May 18, 2017

unpack function on PHP that run in 32bit mode can return negative result as noted by the documentation: https://secure.php.net/manual/en/function.unpack.php#refsect1-function.unpack-notes

Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified.

thus can result in PHP Warning.
example: (run under PHP 32bit)

<?php
$negative32 = pack('CCCC', 0xFF, 0xFF, 0xFF, 0xFF);
file_put_contents('fpdle.mo',"\xde\x12\x04\x95".str_repeat($negative32,6));

include 'vendor/autoload.php';
$t=new PhpMyAdmin\MoTranslator\Translator('fpdle.mo');
print_r($t);
?>

result:

PHP Warning:  unpack(): Type V: not enough input, need 4, have 0 in /vendor/phpmyadmin/motranslator/src/StringReader.php on line 88
PHP Warning:  unpack(): Type V: not enough input, need 4, have 0 in /vendor/phpmyadmin/motranslator/src/StringReader.php on line 88
nijel added a commit that referenced this issue May 22, 2017
Signed-off-by: Michal Čihař <michal@cihar.com>
@nijel nijel added the bug label May 23, 2017
@nijel nijel closed this in f3b2b6a May 23, 2017
@nijel nijel self-assigned this May 23, 2017
@nijel

This comment has been minimized.

Copy link
Member

@nijel nijel commented May 23, 2017

I currently don't have 32-bit system to test, so any feedback on fix is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.