php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73555 imagepng() doesn't properly report failure
Submitted: 2016-11-17 13:18 UTC Modified: 2017-08-16 16:30 UTC
From: cmb@php.net Assigned:
Status: Suspended Package: GD related
PHP Version: 5.6Git-2016-11-17 (Git) OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-11-17 13:18 UTC] cmb@php.net
Description:
------------
imagepng() and other output functions don't properly report
failure. For instance, if a read-only stream is passed to
imagepng(), the function returns TRUE without any warning or
notice, but obviously the image has not been written to the file.



Test script:
---------------
<?php

$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug.png';
touch($filename);
$stream = fopen($filename, 'r');
$im = imagecreatetruecolor(100, 100);
var_dump(imagepng($im, $stream));
var_dump(filesize($filename));


Expected result:
----------------
bool(false)
int(0)

Actual result:
--------------
bool(true)
int(0)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-17 13:19 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-11-17 13:34 UTC] cmb@php.net
-Status: Assigned +Status: Suspended
 [2016-11-17 13:34 UTC] cmb@php.net
Unfortunately, this issue can't be resolved, because GD's image
output functions don't return success/failure[1]. I'm suspending
this ticket until this is resolved.

[1] <https://github.com/libgd/libgd/issues/347>
 [2017-08-16 16:30 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Wed Nov 21 00:01:26 2018 UTC