Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: third_party/libtiff/tif_getimage.c

Issue 2054993002: Apply security fixes to libtiff that are not in 4.0.6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libtiff/README.pdfium ('k') | third_party/libtiff/tif_luv.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* $Id: tif_getimage.c,v 1.90 2015-06-17 01:34:08 bfriesen Exp $ */ 1 /* $Id: tif_getimage.c,v 1.90 2015-06-17 01:34:08 bfriesen Exp $ */
2 2
3 /* 3 /*
4 * Copyright (c) 1991-1997 Sam Leffler 4 * Copyright (c) 1991-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. 5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 * 6 *
7 * Permission to use, copy, modify, distribute, and sell this software and 7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided 8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in 9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of 10 * all copies of the software and related documentation, and (ii) the names of
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 td->td_compression != COMPRESSION_SGILOG24) { 175 td->td_compression != COMPRESSION_SGILOG24) {
176 sprintf(emsg, "Sorry, LogLuv data must have %s=% d or %d", 176 sprintf(emsg, "Sorry, LogLuv data must have %s=% d or %d",
177 "Compression", COMPRESSION_SGILOG, COMPRESSI ON_SGILOG24); 177 "Compression", COMPRESSION_SGILOG, COMPRESSI ON_SGILOG24);
178 return (0); 178 return (0);
179 } 179 }
180 if (td->td_planarconfig != PLANARCONFIG_CONTIG) { 180 if (td->td_planarconfig != PLANARCONFIG_CONTIG) {
181 sprintf(emsg, "Sorry, can not handle LogLuv imag es with %s=%d", 181 sprintf(emsg, "Sorry, can not handle LogLuv imag es with %s=%d",
182 "Planarconfiguration", td->td_planarconfig); 182 "Planarconfiguration", td->td_planarconfig);
183 return (0); 183 return (0);
184 } 184 }
185 » » » if( td->td_samplesperpixel != 3 ) 185 » » » if( td->td_samplesperpixel != 3 || colorchannels != 3 )
186 { 186 {
187 sprintf(emsg, 187 sprintf(emsg,
188 "Sorry, can not handle image with %s=%d", 188 "Sorry, can not handle image with %s=%d, %s=%d",
189 "Samples/pixel", td->td_samplesperpixel); 189 "Samples/pixel", td->td_samplesperpixel,
190 "colorchannels", colorchannels);
190 return 0; 191 return 0;
191 } 192 }
192 break; 193 break;
193 case PHOTOMETRIC_CIELAB: 194 case PHOTOMETRIC_CIELAB:
194 if( td->td_samplesperpixel != 3 || td->td_bitspersample != 8 ) 195 if( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bits persample != 8 )
195 { 196 {
196 sprintf(emsg, 197 sprintf(emsg,
197 "Sorry, can not handle image with %s=%d and %s=%d", 198 "Sorry, can not handle image with %s=%d, %s=%d and %s=%d ",
198 "Samples/pixel", td->td_samplesperpixel, 199 "Samples/pixel", td->td_samplesperpixel,
200 "colorchannels", colorchannels,
199 "Bits/sample", td->td_bitspersample); 201 "Bits/sample", td->td_bitspersample);
200 return 0; 202 return 0;
201 } 203 }
202 break; 204 break;
203 default: 205 default:
204 sprintf(emsg, "Sorry, can not handle image with %s=%d", 206 sprintf(emsg, "Sorry, can not handle image with %s=%d",
205 photoTag, photometric); 207 photoTag, photometric);
206 return (0); 208 return (0);
207 } 209 }
208 return (1); 210 return (1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 int 250 int
249 TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) 251 TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
250 { 252 {
251 uint16* sampleinfo; 253 uint16* sampleinfo;
252 uint16 extrasamples; 254 uint16 extrasamples;
253 uint16 planarconfig; 255 uint16 planarconfig;
254 uint16 compress; 256 uint16 compress;
255 int colorchannels; 257 int colorchannels;
256 uint16 *red_orig, *green_orig, *blue_orig; 258 uint16 *red_orig, *green_orig, *blue_orig;
257 int n_color; 259 int n_color;
260
261 if( !TIFFRGBAImageOK(tif, emsg) )
262 return 0;
258 263
259 /* Initialize to normal values */ 264 /* Initialize to normal values */
260 img->row_offset = 0; 265 img->row_offset = 0;
261 img->col_offset = 0; 266 img->col_offset = 0;
262 img->redcmap = NULL; 267 img->redcmap = NULL;
263 img->greencmap = NULL; 268 img->greencmap = NULL;
264 img->bluecmap = NULL; 269 img->bluecmap = NULL;
265 img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ 270 img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
266 271
267 img->tif = tif; 272 img->tif = tif;
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 */ 2506 */
2502 static int 2507 static int
2503 PickContigCase(TIFFRGBAImage* img) 2508 PickContigCase(TIFFRGBAImage* img)
2504 { 2509 {
2505 img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig; 2510 img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig;
2506 img->put.contig = NULL; 2511 img->put.contig = NULL;
2507 switch (img->photometric) { 2512 switch (img->photometric) {
2508 case PHOTOMETRIC_RGB: 2513 case PHOTOMETRIC_RGB:
2509 switch (img->bitspersample) { 2514 switch (img->bitspersample) {
2510 case 8: 2515 case 8:
2511 » » » » » if (img->alpha == EXTRASAMPLE_ASSOCALPHA ) 2516 » » » » » if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
2517 » » » » » » img->samplesperpixel >= 4)
2512 img->put.contig = putRGBAAcontig 8bittile; 2518 img->put.contig = putRGBAAcontig 8bittile;
2513 » » » » » else if (img->alpha == EXTRASAMPLE_UNASS ALPHA) 2519 » » » » » else if (img->alpha == EXTRASAMPLE_UNASS ALPHA &&
2520 » » » » » » » img->samplesperpixel >= 4)
2514 { 2521 {
2515 if (BuildMapUaToAa(img)) 2522 if (BuildMapUaToAa(img))
2516 img->put.contig = putRGB UAcontig8bittile; 2523 img->put.contig = putRGB UAcontig8bittile;
2517 } 2524 }
2518 » » » » » else 2525 » » » » » else if( img->samplesperpixel >= 3 )
2519 img->put.contig = putRGBcontig8b ittile; 2526 img->put.contig = putRGBcontig8b ittile;
2520 break; 2527 break;
2521 case 16: 2528 case 16:
2522 » » » » » if (img->alpha == EXTRASAMPLE_ASSOCALPHA ) 2529 » » » » » if (img->alpha == EXTRASAMPLE_ASSOCALPHA &&
2530 » » » » » » img->samplesperpixel >=4 )
2523 { 2531 {
2524 if (BuildMapBitdepth16To8(img)) 2532 if (BuildMapBitdepth16To8(img))
2525 img->put.contig = putRGB AAcontig16bittile; 2533 img->put.contig = putRGB AAcontig16bittile;
2526 } 2534 }
2527 » » » » » else if (img->alpha == EXTRASAMPLE_UNASS ALPHA) 2535 » » » » » else if (img->alpha == EXTRASAMPLE_UNASS ALPHA &&
2536 » » » » » » » img->samplesperpixel >= 4 )
2528 { 2537 {
2529 if (BuildMapBitdepth16To8(img) & & 2538 if (BuildMapBitdepth16To8(img) & &
2530 BuildMapUaToAa(img)) 2539 BuildMapUaToAa(img))
2531 img->put.contig = putRGB UAcontig16bittile; 2540 img->put.contig = putRGB UAcontig16bittile;
2532 } 2541 }
2533 » » » » » else 2542 » » » » » else if( img->samplesperpixel >=3 )
2534 { 2543 {
2535 if (BuildMapBitdepth16To8(img)) 2544 if (BuildMapBitdepth16To8(img))
2536 img->put.contig = putRGB contig16bittile; 2545 img->put.contig = putRGB contig16bittile;
2537 } 2546 }
2538 break; 2547 break;
2539 } 2548 }
2540 break; 2549 break;
2541 case PHOTOMETRIC_SEPARATED: 2550 case PHOTOMETRIC_SEPARATED:
2542 » » » if (buildMap(img)) { 2551 » » » if (img->samplesperpixel >=4 && buildMap(img)) {
2543 if (img->bitspersample == 8) { 2552 if (img->bitspersample == 8) {
2544 if (!img->Map) 2553 if (!img->Map)
2545 img->put.contig = putRGBcontig8b itCMYKtile; 2554 img->put.contig = putRGBcontig8b itCMYKtile;
2546 else 2555 else
2547 img->put.contig = putRGBcontig8b itCMYKMaptile; 2556 img->put.contig = putRGBcontig8b itCMYKMaptile;
2548 } 2557 }
2549 } 2558 }
2550 break; 2559 break;
2551 case PHOTOMETRIC_PALETTE: 2560 case PHOTOMETRIC_PALETTE:
2552 if (buildMap(img)) { 2561 if (buildMap(img)) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 img->put.contig = putcon tig8bitYCbCr12tile; 2637 img->put.contig = putcon tig8bitYCbCr12tile;
2629 break; 2638 break;
2630 case 0x11: 2639 case 0x11:
2631 img->put.contig = putcon tig8bitYCbCr11tile; 2640 img->put.contig = putcon tig8bitYCbCr11tile;
2632 break; 2641 break;
2633 } 2642 }
2634 } 2643 }
2635 } 2644 }
2636 break; 2645 break;
2637 case PHOTOMETRIC_CIELAB: 2646 case PHOTOMETRIC_CIELAB:
2638 » » » if (buildMap(img)) { 2647 » » » if (img->samplesperpixel == 3 && buildMap(img)) {
2639 if (img->bitspersample == 8) 2648 if (img->bitspersample == 8)
2640 img->put.contig = initCIELabConversion(i mg); 2649 img->put.contig = initCIELabConversion(i mg);
2641 break; 2650 break;
2642 } 2651 }
2643 } 2652 }
2644 return ((img->get!=NULL) && (img->put.contig!=NULL)); 2653 return ((img->get!=NULL) && (img->put.contig!=NULL));
2645 } 2654 }
2646 2655
2647 /* 2656 /*
2648 * Select the appropriate conversion routine for unpacked data. 2657 * Select the appropriate conversion routine for unpacked data.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 } 2928 }
2920 2929
2921 /* vim: set ts=8 sts=8 sw=8 noet: */ 2930 /* vim: set ts=8 sts=8 sw=8 noet: */
2922 /* 2931 /*
2923 * Local Variables: 2932 * Local Variables:
2924 * mode: c 2933 * mode: c
2925 * c-basic-offset: 8 2934 * c-basic-offset: 8
2926 * fill-column: 78 2935 * fill-column: 78
2927 * End: 2936 * End:
2928 */ 2937 */
OLDNEW
« no previous file with comments | « third_party/libtiff/README.pdfium ('k') | third_party/libtiff/tif_luv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698