php-ext-lz4 icon indicating copy to clipboard operation
php-ext-lz4 copied to clipboard

php unexpected exiting when uncompress the wrong format data

Open liweing opened this issue 10 years ago • 3 comments

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);

liweing avatar Mar 11 '15 12:03 liweing

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

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

kjdev avatar Mar 11 '15 23:03 kjdev

can you please try the string I posted?

liweing avatar Mar 16 '15 11:03 liweing

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)
*/

kjdev avatar Mar 16 '15 22:03 kjdev