overflow an integer would cause too small a buffer to be allocated.
This could potentially be a security hole.
partly resolves https://rt.cpan.org/Ticket/Display.html?id=8213
+- set i_format to jpeg for jpeg files and test for it
=================================================================
(void) jpeg_read_header(&cinfo, TRUE);
(void) jpeg_start_decompress(&cinfo);
im=i_img_empty_ch(NULL,cinfo.output_width,cinfo.output_height,cinfo.output_components);
+ if (!im) {
+ jpeg_destroy_decompress(&cinfo);
+ return NULL;
+ }
row_stride = cinfo.output_width * cinfo.output_components;
buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
while (cinfo.output_scanline < cinfo.output_height) {
(void) jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
*itlength=tlength;
+
+ i_tags_add(&im->tags, "i_format", 0, "jpeg", 4, 0);
+
mm_log((1,"i_readjpeg_wiol -> (0x%x)\n",im));
return im;
}
use Imager qw(:all);
-print "1..8\n";
+print "1..9\n";
init_log("testout/t101jpeg.log",1);
i_has_format("jpeg") && print "# has jpeg\n";
if (!i_has_format("jpeg")) {
- for (1..8) {
+ for (1..9) {
print "ok $_ # skip no jpeg support\n";
}
} else {
ok(8, !$imoo->write(fd=>fileno(FH), type=>'jpeg'), 'failure handling');
close FH;
print "# ",$imoo->errstr,"\n";
+
+ # check that the i_format tag is set
+ my @fmt = $imoo->tags(name=>'i_format');
+ ok(9, @fmt == 1 && $fmt[0] eq 'jpeg', 'i_format tag');
}
sub ok {