Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.

gd imageloadfont, verify error while reading header #142

Closed
wants to merge 1 commit into from
Closed

gd imageloadfont, verify error while reading header #142

wants to merge 1 commit into from

Conversation

BlackIkeEagle
Copy link

when reading the header verify we get an error when the header is
invalid.

Signed-off-by: BlackEagle ike.devolder@gmail.com

User Group: PHP-WVL & PHPGent #PHPTestFest

when reading the header verify we get an error when the header is
invalid.

Signed-off-by: BlackEagle <ike.devolder@gmail.com>
@petk petk self-assigned this Feb 14, 2019
@petk
Copy link
Contributor

petk commented Feb 14, 2019

Thank you for the pull request. Maybe this one should be joined together into this file now also:
php/php-src@fee9f3a

I'll recheck soon.

@BlackIkeEagle
Copy link
Author

@petk do I need to take some action, or do you come back on this?

@petk
Copy link
Contributor

petk commented Feb 18, 2019

Hello, I was thinking here if it's possible to join this test with this file:
https://github.com/php/php-src/blob/master/ext/gd/tests/imageloadfont_end_of_file_while_reading_header.phpt

Can you please open a pull request on the php-src directly and add the part that is here in that file?

Basically, something like this I think is ok:

--TEST--
imageloadfont() "End of file while reading header"
--CREDITS--
Ike Devolder <ike.devolder@gmail.com>
User Group: PHP-WVL & PHPGent #PHPTestFest
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
?>
--FILE--
<?php
$filename = dirname(__FILE__) .  '/font.gdf';

// End of file while reading header
$bin = "\x41\x41\x41\x41\x00\x00\x00\x00\x00\x00";
$fp = fopen($filename, 'wb');
fwrite($fp, $bin);
fclose($fp);
$font = imageloadfont($filename);

// Error while reading header
$bin = "\xe0\x00\x00\x00\x20\x00\x00\x00\x06\x00\x00\x00\x0a\x00\x00";
$fp = fopen($filename, 'wb');
fwrite($fp, $bin);
fclose($fp);
$font = imageloadfont($filename);
?>
--CLEAN--
<?php
unlink(__DIR__.'/font.gdf');
?>
--EXPECTF--
Warning: imageloadfont(): End of file while reading header in %s on line %d

Warning: imageloadfont(): End of file while reading header in %s on line %d

@petk
Copy link
Contributor

petk commented Feb 19, 2019

I've applied the joined tests via php/php-src@a8336fb to PHP-7.4 and master branches.

Thank you @BlackIkeEagle for the pull request 🎉

@petk petk closed this Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants