Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 8213
Status: resolved
Priority: 10/
Queue: Imager

People
Owner: TONYC [...] cpan.org
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Date: Wed, 3 Nov 2004 01:12:08 +1100
From: tonyc [...] cpan.org
To: bug-Imager [...] rt.cpan.org
Subject: integer overflows while allocating images not handled
The following code causes a segmentation fault: # check for handling of memory allocation of very large images use Config; my $uint_range = 256 ** $Config{ivsize}; print "# range $uint_range\n"; my $dim1 = int(sqrt($uint_range)); my $im_b = Imager->new(xsize=>$dim1, ysize=>$dim1, channels=>1); $im_b->box(filled=>1, color=>'#000000'); which seems to be due to incorrect handling of the multiplication when calculating the space needed for image data. The log shows: [2004/11/02 23:48:01] image.c:270 1: ((nil)) <- IIM_new [2004/11/02 23:48:01] image.c:266 1: IIM_new(x 65536,y 65536,ch 1) [2004/11/02 23:48:01] image.c:351 1: i_img_empty_ch(*im (nil), x 65536, y 65536, ch 1) [2004/11/02 23:48:01] io.c:236 1: mymalloc(size 128) -> 0x83d2860 [2004/11/02 23:48:01] io.c:236 1: mymalloc(size 0) -> 0x83d28e8 [2004/11/02 23:48:01] image.c:378 1: (0x83d2860) <- i_img_empty_ch [2004/11/02 23:48:01] image.c:270 1: (0x83d2860) <- IIM_new when creating the image - so the size allocated is zero bytes.
Code for each of the image types has been changed to check that the multiplcation doesn't overflow, and then fail image creation if it does. Various pieces of code that create new image objects (especially the file readers) need to handle the possibility of failure. In some cases they should also have checks added for similar integer overflows (eg. for buffers they use).
Need to check that other image data allocations allocate the correct amount, for example the quantization image allocation
The types code review covered this.
Fixed in 0.85