php-src
php-src copied to clipboard
Zlib:gzinflate operates on invalid string
Description
The following code:
<?php
var_dump(gzinflate('{to"'));
Resulted in this output:
string(3) "�ޑ"
But I expected this output instead:
bool(false)
PHP Version
PHP 8.1.2
Operating System
Linux Mint 20.3 Una
https://3v4l.org/57mcj
so eventually this is as expected or broken for ages.

gzdeflate does not create any checksum, so gzinflate cannot verify if data is actually valid. For that gzencode or gzcomress have to be used. Functions comparison on stack
Indeed, expected behavior. See @KapitanOczywisty's comment.