true when read() or write() is supplied with an fh parameter.
http://rt.cpan.org/Ticket/Display.html?id=35139
- i_scale_axis() wasn't checking the result of i_img_new_ch()
resulting in a SIGSEGV when attempting to scale an image to a size
too large to fit in memory. This is a NULL pointer access issue,
not a buffer overflow.
Added a check for the failure.
scale_calculate() (and hence scale()) will now fail if any of the
scale size parameters are a reference.
http://rt.cpan.org/Ticket/Display.html?id=35172
Imager release history. Older releases can be found in Changes.old
+Imager 0.64 - unreleased
+===========
+
+Bug fixes:
+
+ - check that the result of fileno($fh) is defined rather than simply
+ true when read() or write() is supplied with an fh parameter.
+ http://rt.cpan.org/Ticket/Display.html?id=35139
+
+ - i_scale_axis() wasn't checking the result of i_img_new_ch()
+ resulting in a SIGSEGV when attempting to scale an image to a size
+ too large to fit in memory. This is a NULL pointer access issue,
+ not a buffer overflow.
+ Added a check for the failure.
+ scale_calculate() (and hence scale()) will now fail if any of the
+ scale size parameters are a reference.
+ http://rt.cpan.org/Ticket/Display.html?id=35172
+
Imager 0.63 - 7 April 2008
===========
}
elsif ($input->{fh}) {
my $fd = fileno($input->{fh});
- unless ($fd) {
+ unless (defined $fd) {
$self->_set_error("Handle in fh option not opened");
return;
}
}
elsif ($input->{fh}) {
my $fd = fileno($input->{fh});
- unless ($fd) {
+ unless (defined $fd) {
$self->_set_error("Handle in fh option not opened");
return;
}
my %opts = ('type'=>'max', @_);
+ # none of these should be references
+ for my $name (qw/xpixels ypixels xscalefactor yscalefactor width height/) {
+ if (defined $opts{$name} && ref $opts{$name}) {
+ $self->_set_error("scale_calculate: $name parameter cannot be a reference");
+ return;
+ }
+ }
+
my ($x_scale, $y_scale);
my $width = $opts{width};
my $height = $opts{height};
if ($opts{qtype} eq 'normal') {
$tmp->{IMG} = i_scaleaxis($self->{IMG}, $x_scale, 0);
if ( !defined($tmp->{IMG}) ) {
- $self->{ERRSTR} = 'unable to scale image';
+ $self->{ERRSTR} = 'unable to scale image: ' . $self->_error_as_msg;
return undef;
}
$img->{IMG}=i_scaleaxis($tmp->{IMG}, $y_scale, 1);
if ( !defined($img->{IMG}) ) {
- $self->{ERRSTR}='unable to scale image';
+ $self->{ERRSTR}='unable to scale image: ' . $self->_error_as_msg;
return undef;
}
elsif ($opts{'qtype'} eq 'mixing') {
$img->{IMG} = i_scale_mixing($self->{IMG}, $new_width, $new_height);
unless ($img->{IMG}) {
- $self->_set_error(Imager->_error_as_meg);
+ $self->_set_error(Imager->_error_as_msg);
return;
}
return $img;
i_color val,val1,val2;
i_img *new_img;
+ i_clear_error();
mm_log((1,"i_scaleaxis(im %p,Value %.2f,Axis %d)\n",im,Value,Axis));
}
new_img = i_img_empty_ch(NULL, hsize, vsize, im->channels);
+ if (!new_img) {
+ i_push_error(0, "cannot create output image");
+ return NULL;
+ }
/* 1.4 is a magic number, setting it to 2 will cause rather blurred images */
LanczosWidthFactor = (Value >= 1) ? 1 : (int) (1.4/Value);
#!perl -w
use strict;
-use Test::More tests => 228;
+use Test::More tests => 230;
BEGIN { use_ok(Imager=>':all') }
use Imager::Test qw(is_image is_color4);
"class method scale_factor");
}
+{ # passing a reference for scaling parameters should fail
+ # RT #35172
+ my $im = Imager->new(xsize => 100, ysize => 100);
+ ok(!$im->scale(xpixels => {}), "can't use a reference as a size");
+ cmp_ok($im->errstr, '=~', "xpixels parameter cannot be a reference",
+ "check error message");
+}
+
sub scale_test {
my ($in, $method, $exp_width, $exp_height, $note, @parms) = @_;