"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/GD.t" between
GD-2.71.tar.gz and GD-2.72.tar.gz

About: GD is a Perl5 interface to Thomas Boutell’s gd graphics library.

GD.t  (GD-2.71):GD.t  (GD-2.72)
#!/usr/bin/perl #!/usr/bin/perl
use strict; use strict;
use warnings; use warnings;
use FileHandle; use FileHandle;
use FindBin qw($Bin); use FindBin qw($Bin);
use lib "$Bin/../blib/lib","$Bin/../blib/arch","$Bin/../lib"; use lib "$Bin/../blib/lib","$Bin/../blib/arch","$Bin/../lib";
use constant FONT=>"$Bin/test_data/Generic.ttf"; use constant FONT=>"$Bin/test_data/Generic.ttf";
use constant IMAGE_TESTS => 7; use constant IMAGE_TESTS => 7;
use Test::More tests => 13; use Test::More tests => 14;
use IO::Dir; use IO::Dir;
use_ok('GD',':DEFAULT',':cmp'); use_ok('GD',':DEFAULT',':cmp');
use_ok('GD::Simple'); use_ok('GD::Simple');
chdir $Bin || die "Couldn't change to 't' directory: $!"; chdir $Bin || die "Couldn't change to 't' directory: $!";
my $images = './test_data/images'; my $images = './test_data/images';
my $arg = shift; my $arg = shift;
write_regression_tests() if (defined $arg && $arg eq '--write'); write_regression_tests() if (defined $arg && $arg eq '--write');
run_image_regression_tests(); run_image_regression_tests();
run_round_trip_test(); run_round_trip_test();
catch_libgd_error(); catch_libgd_error();
test_cve2019_6977();
exit 0; exit 0;
sub write_regression_tests { sub write_regression_tests {
warn "Writing regression files..."; warn "Writing regression files...";
for my $suffix ('gd2','gd','png','gif','jpeg') { for my $suffix ('gd2','gd','png','gif','jpeg') {
my $op = ucfirst $suffix; my $op = ucfirst $suffix;
unless (GD::Image->can("newFrom$op")) { unless (GD::Image->can("newFrom$op")) {
print "# not writing $op regression test: not supported\n"; print "# not writing $op regression test: not supported\n";
next; next;
skipping to change at line 287 skipping to change at line 288
$image2 = GD::Image->newFromGd2Data($gd2); $image2 = GD::Image->newFromGd2Data($gd2);
ok(!$image->compare($image2) & GD_CMP_IMAGE(),'round trip gd2'); ok(!$image->compare($image2) & GD_CMP_IMAGE(),'round trip gd2');
} }
sub catch_libgd_error { sub catch_libgd_error {
diag("ignore corrupt png error messages..."); diag("ignore corrupt png error messages...");
my $image = eval { GD::Image->newFromPng("test_data/images/corrupt.png") }; my $image = eval { GD::Image->newFromPng("test_data/images/corrupt.png") };
is($image, undef); is($image, undef);
ok($@, 'caught corrupt png'); ok($@, 'caught corrupt png');
} }
sub test_cve2019_6977 {
my $img1 = GD::Image->new(0xfff, 0xfff, 1);
my $img2 = GD::Image->new(0xfff, 0xfff, 0);
$img2->colorAllocate(0, 0, 0);
$img2->setPixel (0, 0, 255);
if (GD::LIBGD_VERSION() >= 2.10) {
$img1->colorMatch ($img2);
}
ok(1, 'survived CVE 2019-6977'); # fails only under valgrind or asan
}
 End of changes. 3 change blocks. 
1 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)