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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 01:01:28 2025 UTC