php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Zlib:gzinflate operates on invalid string

Open acidspit opened this issue 4 years ago • 3 comments

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

acidspit avatar Feb 11 '22 02:02 acidspit

https://3v4l.org/57mcj

so eventually this is as expected or broken for ages.

image

CyberLine avatar Feb 11 '22 14:02 CyberLine

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

KapitanOczywisty avatar Feb 11 '22 14:02 KapitanOczywisty

Indeed, expected behavior. See @KapitanOczywisty's comment.

cmb69 avatar Feb 14 '22 11:02 cmb69