Bug #78052 [Ver->Asn]: exif_read_data chokes on strict_types for parameter 2

From: Date: Thu, 12 Sep 2019 16:16:55 +0000
Subject: Bug #78052 [Ver->Asn]: exif_read_data chokes on strict_types for parameter 2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222707@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78052&edit=1 ID: 78052 Updated by: kalle@php.net Reported by: c dot schiffler at cyberspectrum dot de Summary: exif_read_data chokes on strict_types for parameter 2 -Status: Verified +Status: Assigned Type: Bug Package: EXIF related Operating System: Linux PHP Version: 7.3.5 -Assigned To: +Assigned To: kalle Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2019-05-23 13:54:49] requinix@php.net Yeah, on second thought an empty string would be weird - PHP does null everywhere for optional arguments, no reason to go against that here. But since someone will be in there anyways I think adding the ZSTR_LEN check is worth it, for hypothetical code like $sections = []; if ($should_get_file) $sections[] = "FILE"; if ($should_get_thumbnail) $sections[] = "THUMBNAIL"; $return = exif_read_data($stream, implode(",", $sections)); ------------------------------------------------------------------------ [2019-05-23 09:20:36] nikic@php.net Agree with cmb, I think it would be better to allow an explicit null here. ------------------------------------------------------------------------ [2019-05-22 22:33:24] cmb@php.net An alternative would be to actually allow passing NULL, i.e. Z_PARAM_STR_EX(z_sections_needed, 1, 0) ------------------------------------------------------------------------ [2019-05-22 19:21:47] requinix@php.net This could be a doc bug (have the argument default to "") however the source tests specifically for null to decide if it should process the argument at all so passing an empty string loses a bit of performance. I think -if (z_sections_needed) { +if (z_sections_needed && ZSTR_LEN(z_sections_needed)) { Then the small edit to the doc for string $sections = "" ------------------------------------------------------------------------ [2019-05-22 19:19:56] spam2 at rhsoft dot net param 2 is type string . period exif_read_data ( mixed $stream [, string $sections = NULL [, bool $arrays = FALSE [, bool $thumbnail = FALSE ]]] ) : array ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78052 -- Edit this bug report at https://bugs.php.net/bug.php?id=78052&edit=1

« previous php.bugs (#222707) next »