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

php unexpected exiting when uncompress the wrong format data #6

Open
liweing opened this issue Mar 11, 2015 · 3 comments
Open

php unexpected exiting when uncompress the wrong format data #6

liweing opened this issue Mar 11, 2015 · 3 comments

Comments

@liweing
Copy link

liweing commented Mar 11, 2015

The code for reproducing issue:

$json_output = base64_decode('{"header":{"code":2003004,"exe_time":"0.0135","info":"product not exist","desc":"Productdoes not exist.","template":{"message":""},"debug":{"file":"/home/work/data/www/shopapi.xiaomi.com/server/api/model/ShoppingModel.php","line":734},"compress":"lz4compress.1"},"body":[],"times":{"redis":{"shopapi_misc":{"conn":["0.0022"],"read":["0.0015","0.0011"]},"pms_cart":{"conn":["0.0006"],"read":["0.0013"]}}}}"');

var_dump($json_output);

$json_output = lz4_uncompress($json_output);

@kjdev
Copy link
Owner

kjdev commented Mar 11, 2015

In the case of wrong format data, return to false.

ex: https://github.com/kjdev/php-ext-lz4/blob/master/tests/issues_06.phpt

@liweing
Copy link
Author

liweing commented Mar 16, 2015

can you please try the string I posted?

@kjdev
Copy link
Owner

kjdev commented Mar 16, 2015

I became such a result.

<?php
$json_output = base64_decode('{"header":{"code":2003004,"exe_time":"0.0135","info":"product not exist","desc":"Productdoes not exist.","template":{"message":""},"debug":{"file":"\/home\/work\/data\/www\/shopapi.xiaomi.com\/server\/api\/model\/ShoppingModel.php","line":734},"compress":"lz4compress.1"},"body":[],"times":{"redis":{"shopapi_misc":{"conn":["0.0022"],"read":["0.0015","0.0011"]},"pms_cart":{"conn":["0.0006"],"read":["0.0013"]}}}}"');

var_dump($json_output); //--> string(198) ".."

$json_output = lz4_uncompress($json_output);

var_dump($json_output); //--> bool(false)

/*
output:
string(198) ".."

Warning: lz4_uncompress : data error in /usr/local/home/kamijo/works/bitbucket/php-ext-lz4/a.php on line 6
bool(false)
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants