Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 79922
Status: resolved
Priority: 0/
Queue: Imager

People
Owner: Nobody in particular
Requestors: perl [...] pied.nu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.84
  • 0.85
  • 0.92
Fixed in: (no value)



Subject: Segfault in convert with bad params
If you hand Imager->convert a bad matrix param, it will segfault. Inclosed is a patch that checks the params and spits out an error if something is wrong.
Subject: Philip-Gwyn_Imager_matrix_segfault-01.diff
Only in Imager-0.92/CountColor: CountColor.bs Only in Imager-0.92/CountColor: CountColor.c Only in Imager-0.92/CountColor: CountColor.o Only in Imager-0.92/CountColor: Makefile Only in Imager-0.92/CountColor: pm_to_blib Only in Imager-0.92/DynTest: DynTest.bs Only in Imager-0.92/DynTest: DynTest.c Only in Imager-0.92/DynTest: DynTest.o Only in Imager-0.92/DynTest: Makefile Only in Imager-0.92/DynTest: linstretch.o Only in Imager-0.92/DynTest: pm_to_blib Only in Imager-0.92/FT2: FT2.bs Only in Imager-0.92/FT2: FT2.c Only in Imager-0.92/FT2: FT2.o Only in Imager-0.92/FT2: Makefile Only in Imager-0.92/FT2: freetyp2.o Only in Imager-0.92/FT2: pm_to_blib Only in Imager-0.92/FT2: testout Only in Imager-0.92/Flines: Flines.bs Only in Imager-0.92/Flines: Flines.c Only in Imager-0.92/Flines: Flines.o Only in Imager-0.92/Flines: Makefile Only in Imager-0.92/Flines: pm_to_blib Only in Imager-0.92/GIF: GIF.bs Only in Imager-0.92/GIF: GIF.c Only in Imager-0.92/GIF: GIF.o Only in Imager-0.92/GIF: Makefile Only in Imager-0.92/GIF: imgif.o Only in Imager-0.92/GIF: pm_to_blib Only in Imager-0.92/GIF: testout Only in Imager-0.92/ICO: ICO.bs Only in Imager-0.92/ICO: ICO.c Only in Imager-0.92/ICO: ICO.o Only in Imager-0.92/ICO: Makefile Only in Imager-0.92/ICO: imicon.o Only in Imager-0.92/ICO: msicon.o Only in Imager-0.92/ICO: pm_to_blib Only in Imager-0.92/ICO: testout Only in Imager-0.92/: Imager.bs Only in Imager-0.92/: Imager.c Only in Imager-0.92/: Imager.o diff -rub Imager-0.92-ORIG/Imager.pm Imager-0.92/Imager.pm --- Imager-0.92-ORIG/Imager.pm 2012-08-14 05:33:54.000000000 -0400 +++ Imager-0.92/Imager.pm 2012-09-28 16:07:43.000000000 -0400 @@ -3575,6 +3575,15 @@ } else { $matrix = $opts{matrix}; + unless( 'ARRAY' eq ref $matrix ) { + $self->{ERRSTR} = "convert matrix must be an arrayref of arrayrefs"; + return undef; + } + foreach my $ch ( @$matrix ) { + next if 'ARRAY' eq ref $ch; + $self->{ERRSTR} = "convert matrix must be an arrayref of arrayrefs"; + return undef; + } } my $new = Imager->new;
Example of bad params: $img->convert( matrix => [ 0.30, 0.56, 0.11 ] ); This second patch will upgrades the above to $img->convert( matrix => [[ 0.30, 0.56, 0.11 ]] ); This is less surprising, but might not be the Right Thing to do.
Subject: Philip-Gwyn_Imager_matrix_segfault-02.diff
Only in Imager-0.92/CountColor: CountColor.bs Only in Imager-0.92/CountColor: CountColor.c Only in Imager-0.92/CountColor: CountColor.o Only in Imager-0.92/CountColor: Makefile Only in Imager-0.92/CountColor: pm_to_blib Only in Imager-0.92/DynTest: DynTest.bs Only in Imager-0.92/DynTest: DynTest.c Only in Imager-0.92/DynTest: DynTest.o Only in Imager-0.92/DynTest: Makefile Only in Imager-0.92/DynTest: linstretch.o Only in Imager-0.92/DynTest: pm_to_blib Only in Imager-0.92/FT2: FT2.bs Only in Imager-0.92/FT2: FT2.c Only in Imager-0.92/FT2: FT2.o Only in Imager-0.92/FT2: Makefile Only in Imager-0.92/FT2: freetyp2.o Only in Imager-0.92/FT2: pm_to_blib Only in Imager-0.92/FT2: testout Only in Imager-0.92/Flines: Flines.bs Only in Imager-0.92/Flines: Flines.c Only in Imager-0.92/Flines: Flines.o Only in Imager-0.92/Flines: Makefile Only in Imager-0.92/Flines: pm_to_blib Only in Imager-0.92/GIF: GIF.bs Only in Imager-0.92/GIF: GIF.c Only in Imager-0.92/GIF: GIF.o Only in Imager-0.92/GIF: Makefile Only in Imager-0.92/GIF: imgif.o Only in Imager-0.92/GIF: pm_to_blib Only in Imager-0.92/GIF: testout Only in Imager-0.92/ICO: ICO.bs Only in Imager-0.92/ICO: ICO.c Only in Imager-0.92/ICO: ICO.o Only in Imager-0.92/ICO: Makefile Only in Imager-0.92/ICO: imicon.o Only in Imager-0.92/ICO: msicon.o Only in Imager-0.92/ICO: pm_to_blib Only in Imager-0.92/ICO: testout Only in Imager-0.92/: Imager.bs Only in Imager-0.92/: Imager.c Only in Imager-0.92/: Imager.o diff -rub Imager-0.92-ORIG/Imager.pm Imager-0.92/Imager.pm --- Imager-0.92-ORIG/Imager.pm 2012-08-14 05:33:54.000000000 -0400 +++ Imager-0.92/Imager.pm 2012-09-28 16:14:54.000000000 -0400 @@ -3575,6 +3575,11 @@ } else { $matrix = $opts{matrix}; + unless( 'ARRAY' eq ref $matrix ) { + $self->{ERRSTR} = "convert matrix must be an arrayref of arrayrefs"; + return undef; + } + $matrix = [ $matrix ] unless 'ARRAY' eq ref $matrix->[0]; } my $new = Imager->new; Only in Imager-0.92/: Imager.pm~ Only in Imager-0.92/JPEG: JPEG.bs Only in Imager-0.92/JPEG: JPEG.c Only in Imager-0.92/JPEG: JPEG.o Only in Imager-0.92/JPEG: Makefile Only in Imager-0.92/JPEG: imexif.o Only in Imager-0.92/JPEG: imjpeg.o Only in Imager-0.92/JPEG: pm_to_blib Only in Imager-0.92/JPEG: testout Only in Imager-0.92/: Makefile Only in Imager-0.92/Mandelbrot: Makefile Only in Imager-0.92/Mandelbrot: Mandelbrot.bs Only in Imager-0.92/Mandelbrot: Mandelbrot.c Only in Imager-0.92/Mandelbrot: Mandelbrot.o Only in Imager-0.92/Mandelbrot: mandel.o Only in Imager-0.92/Mandelbrot: pm_to_blib Only in Imager-0.92/PNG: Makefile Only in Imager-0.92/PNG: PNG.bs Only in Imager-0.92/PNG: PNG.c Only in Imager-0.92/PNG: PNG.o Only in Imager-0.92/PNG: impng.o Only in Imager-0.92/PNG: pm_to_blib Only in Imager-0.92/PNG: testout Only in Imager-0.92/SGI: Makefile Only in Imager-0.92/SGI: SGI.bs Only in Imager-0.92/SGI: SGI.c Only in Imager-0.92/SGI: SGI.o Only in Imager-0.92/SGI: imsgi.o Only in Imager-0.92/SGI: pm_to_blib Only in Imager-0.92/SGI: testout Only in Imager-0.92/T1: Makefile Only in Imager-0.92/T1: T1.bs Only in Imager-0.92/T1: T1.c Only in Imager-0.92/T1: T1.o Only in Imager-0.92/T1: imt1.o Only in Imager-0.92/T1: pm_to_blib Only in Imager-0.92/T1: testout Only in Imager-0.92/TIFF: Makefile Only in Imager-0.92/TIFF: TIFF.bs Only in Imager-0.92/TIFF: TIFF.c Only in Imager-0.92/TIFF: TIFF.o Only in Imager-0.92/TIFF: imtiff.o Only in Imager-0.92/TIFF: pm_to_blib Only in Imager-0.92/TIFF: testout Only in Imager-0.92/W32: Makefile Only in Imager-0.92/W32: Makefile.old Only in Imager-0.92/: blib Only in Imager-0.92/: bmp.o Only in Imager-0.92/: color.o Only in Imager-0.92/: combine.c Only in Imager-0.92/: combine.o Only in Imager-0.92/: compose.c Only in Imager-0.92/: compose.o Only in Imager-0.92/: conv.c Only in Imager-0.92/: conv.o Only in Imager-0.92/: convert.c Only in Imager-0.92/: convert.o Only in Imager-0.92/: datatypes.o Only in Imager-0.92/: draw.o Only in Imager-0.92/: dynaload.o Only in Imager-0.92/dynfilt: Makefile Only in Imager-0.92/dynfilt: dt2.o Only in Imager-0.92/dynfilt: dt2.so Only in Imager-0.92/dynfilt: dyntest.o Only in Imager-0.92/dynfilt: dyntest.so Only in Imager-0.92/dynfilt: flines.o Only in Imager-0.92/dynfilt: flines.so Only in Imager-0.92/dynfilt: mandelbrot.o Only in Imager-0.92/dynfilt: mandelbrot.so Only in Imager-0.92/: error.o Only in Imager-0.92/: feat.o Only in Imager-0.92/: fills.o Only in Imager-0.92/: filters.c Only in Imager-0.92/: filters.o Only in Imager-0.92/: flip.c Only in Imager-0.92/: flip.o Only in Imager-0.92/: font.o Only in Imager-0.92/: gaussian.c Only in Imager-0.92/: gaussian.o Only in Imager-0.92/: hlines.o Only in Imager-0.92/: image.o Only in Imager-0.92/: imconfig.h Only in Imager-0.92/: imext.o Only in Imager-0.92/: img16.o Only in Imager-0.92/: img8.o Only in Imager-0.92/: imgdouble.o Only in Imager-0.92/: io.o Only in Imager-0.92/: iolayer.o Only in Imager-0.92/: limits.o Only in Imager-0.92/: log.o Only in Imager-0.92/: map.o Only in Imager-0.92/: maskimg.o Only in Imager-0.92/: palimg.o Only in Imager-0.92/: paste.c Only in Imager-0.92/: paste.o Only in Imager-0.92/: pm_to_blib Only in Imager-0.92/: pnm.o Only in Imager-0.92/: polygon.o Only in Imager-0.92/: quant.o Only in Imager-0.92/: raw.o Only in Imager-0.92/: regmach.o Only in Imager-0.92/: render.c Only in Imager-0.92/: render.o Only in Imager-0.92/: rotate.c Only in Imager-0.92/: rotate.o Only in Imager-0.92/: rubthru.c Only in Imager-0.92/: rubthru.o Only in Imager-0.92/: scale.c Only in Imager-0.92/: scale.o Only in Imager-0.92/: stackmach.o Only in Imager-0.92/: tags.o Only in Imager-0.92/: testout Only in Imager-0.92/: tga.o Only in Imager-0.92/: trans2.o
On Fri Sep 28 16:11:42 2012, GWYN wrote: Show quoted text
> If you hand Imager->convert a bad matrix param, it will segfault. > Inclosed is a patch that checks the params and spits out an error if > something is wrong.
Imager 0.93 has been released and fixes this problem by fixing the matrix conversion code in the XS i_convert() function to report the bad matrix. Thanks for your report. Tony