diff options
author | fwarmerdam <fwarmerdam> | 2012-06-05 03:24:30 +0000 |
---|---|---|
committer | fwarmerdam <fwarmerdam> | 2012-06-05 03:24:30 +0000 |
commit | d3106cc985ce94aa6dd410b7b1637aa4855c4f98 (patch) | |
tree | ae0244ca22c12d2fe8ef3501afdcf243a8a3c97a | |
parent | b7b7e4bf452cfc09330c0cb25c7e83c134557fe3 (diff) | |
download | libtiff-d3106cc985ce94aa6dd410b7b1637aa4855c4f98.tar.gz |
avoid adjusting h/v_sampling in JPEGPreDecode()
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | libtiff/tif_jpeg.c | 57 |
2 files changed, 16 insertions, 47 deletions
@@ -1,3 +1,9 @@ +2012-06-04 Frank Warmerdam <warmerdam@google.com> + + * libtiff/tif_jpeg.c: Remove code for fixing up h_sampling and v_sampling + in JPEGPreDecode(). If a fixup will be done it needs to be done sooner + in JPEGFixupTagsSubsampling() or else buffer sized may be wrong. + 2012-06-01 Frank Warmerdam <warmerdam@google.com> * tools/tiffinfo.c: Do not try to read image data in EXIF directories. diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index 89d235df..3c8d3bf7 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.107 2012-06-01 21:08:51 fwarmerdam Exp $ */ +/* $Id: tif_jpeg.c,v 1.108 2012-06-05 03:24:30 fwarmerdam Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -1095,50 +1095,13 @@ JPEGPreDecode(TIFF* tif, uint16 s) /* Component 0 should have expected sampling factors */ if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { - TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor, - sp->h_sampling, sp->v_sampling); - - /* - * There are potential security issues here - * for decoders that have already allocated - * buffers based on the expected sampling - * factors. Lets check the sampling factors - * dont exceed what we were expecting. - */ - if (sp->cinfo.d.comp_info[0].h_samp_factor - > sp->h_sampling - || sp->cinfo.d.comp_info[0].v_samp_factor - > sp->v_sampling) { - TIFFErrorExt(tif->tif_clientdata, - module, - "Cannot honour JPEG sampling factors" - " that exceed those specified."); - return (0); - } - - /* - * XXX: Files written by the Intergraph software - * has different sampling factors stored in the - * TIFF tags and in the JPEG structures. We will - * try to deduce Intergraph files by the presense - * of the tag 33918. - */ - if (!TIFFFindField(tif, 33918, TIFF_ANY)) { - TIFFWarningExt(tif->tif_clientdata, module, - "Decompressor will try reading with " - "sampling %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor); - - sp->h_sampling = (uint16) - sp->cinfo.d.comp_info[0].h_samp_factor; - sp->v_sampling = (uint16) - sp->cinfo.d.comp_info[0].v_samp_factor; - } + TIFFErrorExt(tif->tif_clientdata, module, + "Improper JPEG sampling factors %d,%d\n" + "Apparently should be %d,%d.", + sp->cinfo.d.comp_info[0].h_samp_factor, + sp->cinfo.d.comp_info[0].v_samp_factor, + sp->h_sampling, sp->v_sampling); + return (0); } /* Rest should have sampling factors 1,1 */ for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { @@ -1160,11 +1123,11 @@ JPEGPreDecode(TIFF* tif, uint16 s) if (td->td_planarconfig == PLANARCONFIG_CONTIG && sp->photometric == PHOTOMETRIC_YCBCR && sp->jpegcolormode == JPEGCOLORMODE_RGB) { - /* Convert YCbCr to RGB */ + /* Convert YCbCr to RGB */ sp->cinfo.d.jpeg_color_space = JCS_YCbCr; sp->cinfo.d.out_color_space = JCS_RGB; } else { - /* Suppress colorspace handling */ + /* Suppress colorspace handling */ sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; sp->cinfo.d.out_color_space = JCS_UNKNOWN; if (td->td_planarconfig == PLANARCONFIG_CONTIG && |