diff options
author | David Seifert <soap@gentoo.org> | 2017-01-21 21:01:22 +0100 |
---|---|---|
committer | David Seifert <soap@gentoo.org> | 2017-01-21 21:04:09 +0100 |
commit | 19aae64ac3dfc8945dbf9c4edccd835778f81c1d (patch) | |
tree | 8c2032a824ef6535358fa85c2796ce0eabad297c /media-libs/freeimage | |
parent | app-admin/consul: correct github remote-id (diff) | |
download | gentoo-19aae64ac3dfc8945dbf9c4edccd835778f81c1d.tar.gz gentoo-19aae64ac3dfc8945dbf9c4edccd835778f81c1d.tar.bz2 gentoo-19aae64ac3dfc8945dbf9c4edccd835778f81c1d.zip |
media-libs/freeimage: Add patches for CVE-2015-0852 and CVE-2016-5684
Gentoo-bug: 559006, 596350
* EAPI=6
* Make patches -p1 compliant
Package-Manager: Portage-2.3.3, Repoman-2.3.1
Diffstat (limited to 'media-libs/freeimage')
6 files changed, 933 insertions, 38 deletions
diff --git a/media-libs/freeimage/files/freeimage-3.15.4-CVE-2015-0852.patch b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2015-0852.patch new file mode 100644 index 000000000000..e0c4b0cf19c4 --- /dev/null +++ b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2015-0852.patch @@ -0,0 +1,214 @@ +--- a/Source/FreeImage/PluginPCX.cpp ++++ b/Source/FreeImage/PluginPCX.cpp +@@ -30,7 +30,7 @@ + // Constants + headers + // ---------------------------------------------------------- + +-#define IO_BUF_SIZE 2048 ++#define PCX_IO_BUF_SIZE 2048 + + // ---------------------------------------------------------- + +@@ -120,17 +120,17 @@ + + while (length--) { + if (count == 0) { +- if (*ReadPos >= IO_BUF_SIZE - 1 ) { +- if (*ReadPos == IO_BUF_SIZE - 1) { ++ if (*ReadPos >= PCX_IO_BUF_SIZE - 1 ) { ++ if (*ReadPos == PCX_IO_BUF_SIZE - 1) { + // we still have one BYTE, copy it to the start pos + +- *ReadBuf = ReadBuf[IO_BUF_SIZE - 1]; ++ *ReadBuf = ReadBuf[PCX_IO_BUF_SIZE - 1]; + +- io.read_proc(ReadBuf + 1, 1, IO_BUF_SIZE - 1, handle); ++ io.read_proc(ReadBuf + 1, 1, PCX_IO_BUF_SIZE - 1, handle); + } else { + // read the complete buffer + +- io.read_proc(ReadBuf, 1, IO_BUF_SIZE, handle); ++ io.read_proc(ReadBuf, 1, PCX_IO_BUF_SIZE, handle); + } + + *ReadPos = 0; +@@ -346,19 +346,9 @@ + BOOL header_only = (flags & FIF_LOAD_NOPIXELS) == FIF_LOAD_NOPIXELS; + + try { +- // check PCX identifier +- +- long start_pos = io->tell_proc(handle); +- BOOL validated = pcx_validate(io, handle); +- io->seek_proc(handle, start_pos, SEEK_SET); +- if(!validated) { +- throw FI_MSG_ERROR_MAGIC_NUMBER; +- } +- +- // process the header +- + PCXHEADER header; + ++ // process the header + if(io->read_proc(&header, sizeof(PCXHEADER), 1, handle) != 1) { + throw FI_MSG_ERROR_PARSING; + } +@@ -366,20 +356,38 @@ + SwapHeader(&header); + #endif + +- // allocate a new DIB ++ // process the window ++ const WORD *window = header.window; // left, upper, right,lower pixel coord. ++ const int left = window[0]; ++ const int top = window[1]; ++ const int right = window[2]; ++ const int bottom = window[3]; + +- unsigned width = header.window[2] - header.window[0] + 1; +- unsigned height = header.window[3] - header.window[1] + 1; +- unsigned bitcount = header.bpp * header.planes; ++ // check image size ++ if((left >= right) || (top >= bottom)) { ++ throw FI_MSG_ERROR_PARSING; ++ } + +- if (bitcount == 24) { +- dib = FreeImage_AllocateHeader(header_only, width, height, bitcount, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); +- } else { +- dib = FreeImage_AllocateHeader(header_only, width, height, bitcount); ++ const unsigned width = right - left + 1; ++ const unsigned height = bottom - top + 1; ++ const unsigned bitcount = header.bpp * header.planes; ++ ++ // allocate a new dib ++ switch(bitcount) { ++ case 1: ++ case 4: ++ case 8: ++ dib = FreeImage_AllocateHeader(header_only, width, height, bitcount); ++ break; ++ case 24: ++ dib = FreeImage_AllocateHeader(header_only, width, height, bitcount, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); ++ break; ++ default: ++ throw FI_MSG_ERROR_DIB_MEMORY; ++ break; + } + + // if the dib couldn't be allocated, throw an error +- + if (!dib) { + throw FI_MSG_ERROR_DIB_MEMORY; + } +@@ -426,19 +434,23 @@ + + if (palette_id == 0x0C) { + BYTE *cmap = (BYTE*)malloc(768 * sizeof(BYTE)); +- io->read_proc(cmap, 768, 1, handle); + +- pal = FreeImage_GetPalette(dib); +- BYTE *pColormap = &cmap[0]; ++ if(cmap) { ++ io->read_proc(cmap, 768, 1, handle); + +- for(int i = 0; i < 256; i++) { +- pal[i].rgbRed = pColormap[0]; +- pal[i].rgbGreen = pColormap[1]; +- pal[i].rgbBlue = pColormap[2]; +- pColormap += 3; ++ pal = FreeImage_GetPalette(dib); ++ BYTE *pColormap = &cmap[0]; ++ ++ for(int i = 0; i < 256; i++) { ++ pal[i].rgbRed = pColormap[0]; ++ pal[i].rgbGreen = pColormap[1]; ++ pal[i].rgbBlue = pColormap[2]; ++ pColormap += 3; ++ } ++ ++ free(cmap); + } + +- free(cmap); + } + + // wrong palette ID, perhaps a gray scale is needed ? +@@ -463,12 +475,12 @@ + return dib; + } + +- // calculate the line length for the PCX and the DIB ++ // calculate the line length for the PCX and the dib + + // length of raster line in bytes +- unsigned linelength = header.bytes_per_line * header.planes; +- // length of DIB line (rounded to DWORD) in bytes +- unsigned pitch = FreeImage_GetPitch(dib); ++ const unsigned linelength = header.bytes_per_line * header.planes; ++ // length of dib line (rounded to DWORD) in bytes ++ const unsigned pitch = FreeImage_GetPitch(dib); + + // run-length encoding ? + +@@ -478,14 +490,18 @@ + // --------------- + + line = (BYTE*)malloc(linelength * sizeof(BYTE)); +- if(!line) throw FI_MSG_ERROR_MEMORY; ++ if(!line) { ++ throw FI_MSG_ERROR_MEMORY; ++ } + +- ReadBuf = (BYTE*)malloc(IO_BUF_SIZE * sizeof(BYTE)); +- if(!ReadBuf) throw FI_MSG_ERROR_MEMORY; ++ ReadBuf = (BYTE*)malloc(PCX_IO_BUF_SIZE * sizeof(BYTE)); ++ if(!ReadBuf) { ++ throw FI_MSG_ERROR_MEMORY; ++ } + + bits = FreeImage_GetScanLine(dib, height - 1); + +- int ReadPos = IO_BUF_SIZE; ++ int ReadPos = PCX_IO_BUF_SIZE; + + if ((header.planes == 1) && ((header.bpp == 1) || (header.bpp == 8))) { + BYTE skip; +@@ -497,7 +513,7 @@ + // skip trailing garbage at the end of the scanline + + for (unsigned count = written; count < linelength; count++) { +- if (ReadPos < IO_BUF_SIZE) { ++ if (ReadPos < PCX_IO_BUF_SIZE) { + ReadPos++; + } else { + io->read_proc(&skip, sizeof(BYTE), 1, handle); +@@ -513,7 +529,9 @@ + unsigned x, y, written; + + buffer = (BYTE*)malloc(width * sizeof(BYTE)); +- if(!buffer) throw FI_MSG_ERROR_MEMORY; ++ if(!buffer) { ++ throw FI_MSG_ERROR_MEMORY; ++ } + + for (y = 0; y < height; y++) { + written = readline(*io, handle, line, linelength, bIsRLE, ReadBuf, &ReadPos); +@@ -532,7 +550,7 @@ + } + } + +- // then write the DIB row ++ // then write the dib row + + for (x = 0; x < width / 2; x++) { + bits[x] = (buffer[2*x] << 4) | buffer[2*x+1]; +@@ -541,7 +559,7 @@ + // skip trailing garbage at the end of the scanline + + for (unsigned count = written; count < linelength; count++) { +- if (ReadPos < IO_BUF_SIZE) { ++ if (ReadPos < PCX_IO_BUF_SIZE) { + ReadPos++; + } else { + io->read_proc(&skip, sizeof(BYTE), 1, handle); diff --git a/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-1.patch b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-1.patch new file mode 100644 index 000000000000..1e94602e0e5e --- /dev/null +++ b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-1.patch @@ -0,0 +1,23 @@ +--- a/Source/FreeImage/PluginXPM.cpp ++++ b/Source/FreeImage/PluginXPM.cpp +@@ -181,6 +181,11 @@ + } + free(str); + ++ // check info string ++ if((width <= 0) || (height <= 0) || (colors <= 0) || (cpp <= 0)) { ++ throw "Improperly formed info string"; ++ } ++ + if (colors > 256) { + dib = FreeImage_AllocateHeader(header_only, width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + } else { +@@ -193,7 +198,7 @@ + FILE_RGBA rgba; + + str = ReadString(io, handle); +- if(!str) ++ if(!str || (strlen(str) < cpp)) + throw "Error reading color strings"; + + std::string chrs(str,cpp); //create a string for the color chars using the first cpp chars diff --git a/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-2.patch b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-2.patch new file mode 100644 index 000000000000..542a9aeab094 --- /dev/null +++ b/media-libs/freeimage/files/freeimage-3.15.4-CVE-2016-5684-2.patch @@ -0,0 +1,11 @@ +--- a/Source/FreeImage/PluginXPM.cpp ++++ b/Source/FreeImage/PluginXPM.cpp +@@ -198,7 +198,7 @@ + FILE_RGBA rgba; + + str = ReadString(io, handle); +- if(!str || (strlen(str) < cpp)) ++ if(!str || (strlen(str) < (size_t)cpp)) + throw "Error reading color strings"; + + std::string chrs(str,cpp); //create a string for the color chars using the first cpp chars diff --git a/media-libs/freeimage/files/freeimage-3.15.4-libjpeg-turbo.patch b/media-libs/freeimage/files/freeimage-3.15.4-libjpeg-turbo.patch new file mode 100644 index 000000000000..62037c59deb2 --- /dev/null +++ b/media-libs/freeimage/files/freeimage-3.15.4-libjpeg-turbo.patch @@ -0,0 +1,531 @@ +--- /dev/null ++++ b/LibJPEG/jpegcomp.h +@@ -0,0 +1,26 @@ ++/* ++ * jpegcomp.h ++ * ++ * Copyright (C) 2010, D. R. Commander ++ * For conditions of distribution and use, see the accompanying README file. ++ * ++ * JPEG compatibility macros ++ * These declarations are considered internal to the JPEG library; most ++ * applications using the library shouldn't need to include this file. ++ */ ++ ++#if JPEG_LIB_VERSION >= 70 ++#define _DCT_scaled_size DCT_h_scaled_size ++#define _min_DCT_scaled_size min_DCT_h_scaled_size ++#define _min_DCT_h_scaled_size min_DCT_h_scaled_size ++#define _min_DCT_v_scaled_size min_DCT_v_scaled_size ++#define _jpeg_width jpeg_width ++#define _jpeg_height jpeg_height ++#else ++#define _DCT_scaled_size DCT_scaled_size ++#define _min_DCT_scaled_size min_DCT_scaled_size ++#define _min_DCT_h_scaled_size min_DCT_scaled_size ++#define _min_DCT_v_scaled_size min_DCT_scaled_size ++#define _jpeg_width image_width ++#define _jpeg_height image_height ++#endif +--- a/LibJPEG/jpegint.h ++++ b/LibJPEG/jpegint.h +@@ -2,7 +2,7 @@ + * jpegint.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. +- * Modified 1997-2011 by Guido Vollbeding. ++ * Modified 1997-2009 by Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -100,16 +100,14 @@ + }; + + /* Forward DCT (also controls coefficient quantization) */ +-typedef JMETHOD(void, forward_DCT_ptr, +- (j_compress_ptr cinfo, jpeg_component_info * compptr, +- JSAMPARRAY sample_data, JBLOCKROW coef_blocks, +- JDIMENSION start_row, JDIMENSION start_col, +- JDIMENSION num_blocks)); +- + struct jpeg_forward_dct { + JMETHOD(void, start_pass, (j_compress_ptr cinfo)); +- /* It is useful to allow each component to have a separate FDCT method. */ +- forward_DCT_ptr forward_DCT[MAX_COMPONENTS]; ++ /* perhaps this should be an array??? */ ++ JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, ++ jpeg_component_info * compptr, ++ JSAMPARRAY sample_data, JBLOCKROW coef_blocks, ++ JDIMENSION start_row, JDIMENSION start_col, ++ JDIMENSION num_blocks)); + }; + + /* Entropy encoding */ +@@ -213,6 +211,10 @@ + JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); + JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, + JBLOCKROW *MCU_data)); ++ ++ /* This is here to share code between baseline and progressive decoders; */ ++ /* other modules probably should not use it */ ++ boolean insufficient_data; /* set TRUE after emitting warning */ + }; + + /* Inverse DCT (also performs dequantization) */ +@@ -302,6 +304,7 @@ + #define jinit_downsampler jIDownsampler + #define jinit_forward_dct jIFDCT + #define jinit_huff_encoder jIHEncoder ++#define jinit_phuff_encoder jIPHEncoder + #define jinit_arith_encoder jIAEncoder + #define jinit_marker_writer jIMWriter + #define jinit_master_decompress jIDMaster +@@ -311,6 +314,7 @@ + #define jinit_input_controller jIInCtlr + #define jinit_marker_reader jIMReader + #define jinit_huff_decoder jIHDecoder ++#define jinit_phuff_decoder jIPHDecoder + #define jinit_arith_decoder jIADecoder + #define jinit_inverse_dct jIIDCT + #define jinit_upsampler jIUpsampler +@@ -321,41 +325,15 @@ + #define jinit_memory_mgr jIMemMgr + #define jdiv_round_up jDivRound + #define jround_up jRound +-#define jzero_far jZeroFar + #define jcopy_sample_rows jCopySamples + #define jcopy_block_row jCopyBlocks ++#define jzero_far jZeroFar + #define jpeg_zigzag_order jZIGTable + #define jpeg_natural_order jZAGTable +-#define jpeg_natural_order7 jZAG7Table +-#define jpeg_natural_order6 jZAG6Table +-#define jpeg_natural_order5 jZAG5Table +-#define jpeg_natural_order4 jZAG4Table +-#define jpeg_natural_order3 jZAG3Table +-#define jpeg_natural_order2 jZAG2Table + #define jpeg_aritab jAriTab + #endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +-/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays +- * and coefficient-block arrays. This won't work on 80x86 because the arrays +- * are FAR and we're assuming a small-pointer memory model. However, some +- * DOS compilers provide far-pointer versions of memcpy() and memset() even +- * in the small-model libraries. These will be used if USE_FMEM is defined. +- * Otherwise, the routines in jutils.c do it the hard way. +- */ +- +-#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ +-#define FMEMZERO(target,size) MEMZERO(target,size) +-#else /* 80x86 case */ +-#ifdef USE_FMEM +-#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) +-#else +-EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); +-#define FMEMZERO(target,size) jzero_far(target, size) +-#endif +-#endif +- +- + /* Compression module initialization routines */ + EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); + EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, +@@ -370,6 +348,7 @@ + EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); + EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); + EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); ++EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); + EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo)); + EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); + /* Decompression module initialization routines */ +@@ -383,6 +362,7 @@ + EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); + EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); + EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); ++EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); + EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo)); + EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); + EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); +@@ -401,17 +381,12 @@ + int num_rows, JDIMENSION num_cols)); + EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, + JDIMENSION num_blocks)); ++EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); + /* Constant tables in jutils.c */ + #if 0 /* This table is not actually needed in v6a */ + extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ + #endif + extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ +-extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */ +-extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */ +-extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */ +-extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */ +-extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */ +-extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */ + + /* Arithmetic coding probability estimation tables in jaricom.c */ + extern const INT32 jpeg_aritab[]; +--- a/LibJPEG/transupp.h ++++ b/LibJPEG/transupp.h +@@ -1,7 +1,7 @@ + /* + * transupp.h + * +- * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. ++ * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -57,7 +57,6 @@ + * corner up and/or left to make it so, simultaneously increasing the region + * dimensions to keep the lower right crop corner unchanged. (Thus, the + * output image covers at least the requested region, but may cover more.) +- * The adjustment of the region dimensions may be optionally disabled. + * + * We also provide a lossless-resize option, which is kind of a lossless-crop + * operation in the DCT coefficient block domain - it discards higher-order +@@ -107,15 +106,13 @@ + + /* + * Codes for crop parameters, which can individually be unspecified, +- * positive or negative for xoffset or yoffset, +- * positive or forced for width or height. ++ * positive, or negative. (Negative width or height makes no sense, though.) + */ + + typedef enum { +- JCROP_UNSET, +- JCROP_POS, +- JCROP_NEG, +- JCROP_FORCE ++ JCROP_UNSET, ++ JCROP_POS, ++ JCROP_NEG + } JCROP_CODE; + + /* +@@ -131,14 +128,21 @@ + boolean trim; /* if TRUE, trim partial MCUs as needed */ + boolean force_grayscale; /* if TRUE, convert color image to grayscale */ + boolean crop; /* if TRUE, crop source image */ ++ boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform ++ normally modifies the source coefficients in place. ++ Setting this to TRUE will instead use a slower, ++ double-buffered algorithm, which leaves the source ++ coefficients in tact (necessary if other transformed ++ images must be generated from the same set of ++ coefficients. */ + + /* Crop parameters: application need not set these unless crop is TRUE. + * These can be filled in by jtransform_parse_crop_spec(). + */ + JDIMENSION crop_width; /* Width of selected region */ +- JCROP_CODE crop_width_set; /* (forced disables adjustment) */ ++ JCROP_CODE crop_width_set; + JDIMENSION crop_height; /* Height of selected region */ +- JCROP_CODE crop_height_set; /* (forced disables adjustment) */ ++ JCROP_CODE crop_height_set; + JDIMENSION crop_xoffset; /* X offset of selected region */ + JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */ + JDIMENSION crop_yoffset; /* Y offset of selected region */ +--- a/LibJPEG/transupp.c ++++ b/LibJPEG/transupp.c +@@ -1,7 +1,8 @@ + /* + * transupp.c + * +- * Copyright (C) 1997-2011, Thomas G. Lane, Guido Vollbeding. ++ * Copyright (C) 1997-2009, Thomas G. Lane, Guido Vollbeding. ++ * Copyright (C) 2010, D. R. Commander. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * +@@ -20,9 +21,19 @@ + #include "jinclude.h" + #include "jpeglib.h" + #include "transupp.h" /* My own external interface */ ++#include "jpegcomp.h" + #include <ctype.h> /* to declare isdigit() */ + + ++#if JPEG_LIB_VERSION >= 70 ++#define dstinfo_min_DCT_h_scaled_size dstinfo->min_DCT_h_scaled_size ++#define dstinfo_min_DCT_v_scaled_size dstinfo->min_DCT_v_scaled_size ++#else ++#define dstinfo_min_DCT_h_scaled_size DCTSIZE ++#define dstinfo_min_DCT_v_scaled_size DCTSIZE ++#endif ++ ++ + #if TRANSFORMS_SUPPORTED + + /* +@@ -134,7 +145,7 @@ + * Partial iMCUs at the right edge are left untouched. + */ + MCU_cols = srcinfo->output_width / +- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); ++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -200,7 +211,7 @@ + * this is essentially the same as the routine above. + */ + MCU_cols = srcinfo->output_width / +- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); ++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -265,7 +276,7 @@ + * Partial iMCUs at the bottom edge are copied verbatim. + */ + MCU_rows = srcinfo->output_height / +- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); ++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -393,7 +404,7 @@ + * not mirrored. + */ + MCU_cols = srcinfo->output_height / +- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); ++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -474,7 +485,7 @@ + * not mirrored. + */ + MCU_rows = srcinfo->output_width / +- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); ++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -542,9 +553,9 @@ + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_width / +- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); ++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_height / +- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); ++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -653,9 +664,9 @@ + jpeg_component_info *compptr; + + MCU_cols = srcinfo->output_height / +- (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); ++ (dstinfo->max_h_samp_factor * dstinfo_min_DCT_h_scaled_size); + MCU_rows = srcinfo->output_width / +- (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); ++ (dstinfo->max_v_samp_factor * dstinfo_min_DCT_v_scaled_size); + + for (ci = 0; ci < dstinfo->num_components; ci++) { + compptr = dstinfo->comp_info + ci; +@@ -771,7 +782,7 @@ + * The routine returns TRUE if the spec string is valid, FALSE if not. + * + * The crop spec string should have the format +- * <width>[f]x<height>[f]{+-}<xoffset>{+-}<yoffset> ++ * <width>x<height>{+-}<xoffset>{+-}<yoffset> + * where width, height, xoffset, and yoffset are unsigned integers. + * Each of the elements can be omitted to indicate a default value. + * (A weakness of this style is that it is not possible to omit xoffset +@@ -793,22 +804,14 @@ + /* fetch width */ + if (! jt_read_integer(&spec, &info->crop_width)) + return FALSE; +- if (*spec == 'f' || *spec == 'F') { +- spec++; +- info->crop_width_set = JCROP_FORCE; +- } else +- info->crop_width_set = JCROP_POS; ++ info->crop_width_set = JCROP_POS; + } +- if (*spec == 'x' || *spec == 'X') { ++ if (*spec == 'x' || *spec == 'X') { + /* fetch height */ + spec++; + if (! jt_read_integer(&spec, &info->crop_height)) + return FALSE; +- if (*spec == 'f' || *spec == 'F') { +- spec++; +- info->crop_height_set = JCROP_FORCE; +- } else +- info->crop_height_set = JCROP_POS; ++ info->crop_height_set = JCROP_POS; + } + if (*spec == '+' || *spec == '-') { + /* fetch xoffset */ +@@ -897,7 +900,12 @@ + info->num_components = srcinfo->num_components; + + /* Compute output image dimensions and related values. */ ++#if JPEG_LIB_VERSION >= 80 + jpeg_core_output_dimensions(srcinfo); ++#else ++ srcinfo->output_width = srcinfo->image_width; ++ srcinfo->output_height = srcinfo->image_height; ++#endif + + /* Return right away if -perfect is given and transformation is not perfect. + */ +@@ -905,15 +913,15 @@ + if (info->num_components == 1) { + if (!jtransform_perfect_transform(srcinfo->output_width, + srcinfo->output_height, +- srcinfo->min_DCT_h_scaled_size, +- srcinfo->min_DCT_v_scaled_size, ++ srcinfo->_min_DCT_h_scaled_size, ++ srcinfo->_min_DCT_v_scaled_size, + info->transform)) + return FALSE; + } else { + if (!jtransform_perfect_transform(srcinfo->output_width, + srcinfo->output_height, +- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size, +- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size, ++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size, ++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size, + info->transform)) + return FALSE; + } +@@ -932,26 +940,26 @@ + info->output_width = srcinfo->output_height; + info->output_height = srcinfo->output_width; + if (info->num_components == 1) { +- info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size; +- info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size; ++ info->iMCU_sample_width = srcinfo->_min_DCT_v_scaled_size; ++ info->iMCU_sample_height = srcinfo->_min_DCT_h_scaled_size; + } else { + info->iMCU_sample_width = +- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; ++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size; + info->iMCU_sample_height = +- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; ++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size; + } + break; + default: + info->output_width = srcinfo->output_width; + info->output_height = srcinfo->output_height; + if (info->num_components == 1) { +- info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size; +- info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size; ++ info->iMCU_sample_width = srcinfo->_min_DCT_h_scaled_size; ++ info->iMCU_sample_height = srcinfo->_min_DCT_v_scaled_size; + } else { + info->iMCU_sample_width = +- srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; ++ srcinfo->max_h_samp_factor * srcinfo->_min_DCT_h_scaled_size; + info->iMCU_sample_height = +- srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; ++ srcinfo->max_v_samp_factor * srcinfo->_min_DCT_v_scaled_size; + } + break; + } +@@ -988,16 +996,10 @@ + else + yoffset = info->crop_yoffset; + /* Now adjust so that upper left corner falls at an iMCU boundary */ +- if (info->crop_width_set == JCROP_FORCE) +- info->output_width = info->crop_width; +- else +- info->output_width = +- info->crop_width + (xoffset % info->iMCU_sample_width); +- if (info->crop_height_set == JCROP_FORCE) +- info->output_height = info->crop_height; +- else +- info->output_height = +- info->crop_height + (yoffset % info->iMCU_sample_height); ++ info->output_width = ++ info->crop_width + (xoffset % info->iMCU_sample_width); ++ info->output_height = ++ info->crop_height + (yoffset % info->iMCU_sample_height); + /* Save x/y offsets measured in iMCUs */ + info->x_crop_offset = xoffset / info->iMCU_sample_width; + info->y_crop_offset = yoffset / info->iMCU_sample_height; +@@ -1020,7 +1022,7 @@ + case JXFORM_FLIP_H: + if (info->trim) + trim_right_edge(info, srcinfo->output_width); +- if (info->y_crop_offset != 0) ++ if (info->y_crop_offset != 0 || info->slow_hflip) + need_workspace = TRUE; + /* do_flip_h_no_crop doesn't need a workspace array */ + break; +@@ -1124,9 +1126,11 @@ + jtemp = dstinfo->image_width; + dstinfo->image_width = dstinfo->image_height; + dstinfo->image_height = jtemp; ++#if JPEG_LIB_VERSION >= 70 + itemp = dstinfo->min_DCT_h_scaled_size; + dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size; + dstinfo->min_DCT_v_scaled_size = itemp; ++#endif + + /* Transpose sampling factors */ + for (ci = 0; ci < dstinfo->num_components; ci++) { +@@ -1362,8 +1366,10 @@ + /* Correct the destination's image dimensions as necessary + * for rotate/flip, resize, and crop operations. + */ ++#if JPEG_LIB_VERSION >= 70 + dstinfo->jpeg_width = info->output_width; + dstinfo->jpeg_height = info->output_height; ++#endif + + /* Transpose destination image parameters */ + switch (info->transform) { +@@ -1371,9 +1377,17 @@ + case JXFORM_TRANSVERSE: + case JXFORM_ROT_90: + case JXFORM_ROT_270: ++#if JPEG_LIB_VERSION < 70 ++ dstinfo->image_width = info->output_height; ++ dstinfo->image_height = info->output_width; ++#endif + transpose_critical_parameters(dstinfo); + break; + default: ++#if JPEG_LIB_VERSION < 70 ++ dstinfo->image_width = info->output_width; ++ dstinfo->image_height = info->output_height; ++#endif + break; + } + +@@ -1389,6 +1403,7 @@ + GETJOCTET(srcinfo->marker_list->data[5]) == 0) { + /* Suppress output of JFIF marker */ + dstinfo->write_JFIF_header = FALSE; ++#if JPEG_LIB_VERSION >= 70 + /* Adjust Exif image parameters */ + if (dstinfo->jpeg_width != srcinfo->image_width || + dstinfo->jpeg_height != srcinfo->image_height) +@@ -1396,6 +1411,7 @@ + adjust_exif_parameters(srcinfo->marker_list->data + 6, + srcinfo->marker_list->data_length - 6, + dstinfo->jpeg_width, dstinfo->jpeg_height); ++#endif + } + + /* Return the appropriate output data set */ +@@ -1432,7 +1448,7 @@ + src_coef_arrays, dst_coef_arrays); + break; + case JXFORM_FLIP_H: +- if (info->y_crop_offset != 0) ++ if (info->y_crop_offset != 0 || info->slow_hflip) + do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, + src_coef_arrays, dst_coef_arrays); + else diff --git a/media-libs/freeimage/files/freeimage-3.15.4-unbundling.patch b/media-libs/freeimage/files/freeimage-3.15.4-unbundling.patch index f770b7ecf773..ac2ac54ce5cf 100644 --- a/media-libs/freeimage/files/freeimage-3.15.4-unbundling.patch +++ b/media-libs/freeimage/files/freeimage-3.15.4-unbundling.patch @@ -5,8 +5,8 @@ lots of fixes here: - make static lib build optional - link with CXX and CXXFLAGS (since this is C++ code) ---- Makefile.gnu -+++ Makefile.gnu +--- a/Makefile.gnu ++++ b/Makefile.gnu @@ -11,7 +11,24 @@ # Converts cr/lf to just lf DOS2UNIX = dos2unix @@ -53,8 +53,8 @@ lots of fixes here: ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME) ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME) # ldconfig ---- Source/FreeImage/J2KHelper.cpp -+++ Source/FreeImage/J2KHelper.cpp +--- a/Source/FreeImage/J2KHelper.cpp ++++ b/Source/FreeImage/J2KHelper.cpp @@ -21,7 +21,7 @@ #include "FreeImage.h" @@ -64,8 +64,8 @@ lots of fixes here: /** Divide an integer by a power of 2 and round upwards ---- Source/FreeImage/PluginEXR.cpp -+++ Source/FreeImage/PluginEXR.cpp +--- a/Source/FreeImage/PluginEXR.cpp ++++ b/Source/FreeImage/PluginEXR.cpp @@ -22,16 +22,16 @@ #include "FreeImage.h" @@ -93,8 +93,8 @@ lots of fixes here: // ========================================================== ---- Source/FreeImage/PluginJ2K.cpp -+++ Source/FreeImage/PluginJ2K.cpp +--- a/Source/FreeImage/PluginJ2K.cpp ++++ b/Source/FreeImage/PluginJ2K.cpp @@ -21,7 +21,7 @@ #include "FreeImage.h" @@ -104,8 +104,8 @@ lots of fixes here: // ========================================================== // Plugin Interface ---- Source/FreeImage/PluginJP2.cpp -+++ Source/FreeImage/PluginJP2.cpp +--- a/Source/FreeImage/PluginJP2.cpp ++++ b/Source/FreeImage/PluginJP2.cpp @@ -21,7 +21,7 @@ #include "FreeImage.h" @@ -115,8 +115,8 @@ lots of fixes here: // ========================================================== // Plugin Interface ---- Source/FreeImage/PluginPNG.cpp -+++ Source/FreeImage/PluginPNG.cpp +--- a/Source/FreeImage/PluginPNG.cpp ++++ b/Source/FreeImage/PluginPNG.cpp @@ -37,8 +37,8 @@ // ---------------------------------------------------------- @@ -128,8 +128,8 @@ lots of fixes here: // ---------------------------------------------------------- ---- Source/transupp.c -+++ Source/transupp.c +--- a/Source/transupp.c ++++ b/Source/transupp.c @@ -15,8 +15,7 @@ /* Although this file really shouldn't have access to the library internals, * it's helpful to let it call jround_up() and jcopy_block_row(). @@ -140,8 +140,8 @@ lots of fixes here: #include "jinclude.h" #include "jpeglib.h" #include "transupp.h" /* My own external interface */ ---- Source/FreeImage/ZLibInterface.cpp -+++ Source/FreeImage/ZLibInterface.cpp +--- a/Source/FreeImage/ZLibInterface.cpp ++++ b/Source/FreeImage/ZLibInterface.cpp @@ -19,10 +19,10 @@ // Use at your own risk! // ========================================================== @@ -155,8 +155,8 @@ lots of fixes here: /** Compresses a source buffer into a target buffer, using the ZLib library. ---- Source/FreeImage/PluginG3.cpp -+++ Source/FreeImage/PluginG3.cpp +--- a/Source/FreeImage/PluginG3.cpp ++++ b/Source/FreeImage/PluginG3.cpp @@ -20,7 +20,7 @@ // Use at your own risk! // ========================================================== @@ -166,8 +166,8 @@ lots of fixes here: #include "FreeImage.h" #include "Utilities.h" ---- Source/FreeImage/PluginJPEG.cpp -+++ Source/FreeImage/PluginJPEG.cpp +--- a/Source/FreeImage/PluginJPEG.cpp ++++ b/Source/FreeImage/PluginJPEG.cpp @@ -35,11 +35,15 @@ #undef FAR #include <setjmp.h> @@ -187,8 +187,8 @@ lots of fixes here: #include "FreeImage.h" #include "Utilities.h" ---- Source/FreeImageToolkit/JPEGTransform.cpp -+++ Source/FreeImageToolkit/JPEGTransform.cpp +--- a/Source/FreeImageToolkit/JPEGTransform.cpp ++++ b/Source/FreeImageToolkit/JPEGTransform.cpp @@ -25,10 +25,11 @@ #undef FAR #include <setjmp.h> @@ -205,8 +205,8 @@ lots of fixes here: } #include "FreeImage.h" ---- Makefile.fip -+++ Makefile.fip +--- a/Makefile.fip ++++ b/Makefile.fip @@ -11,7 +11,24 @@ # Converts cr/lf to just lf DOS2UNIX = dos2unix @@ -257,8 +257,8 @@ lots of fixes here: clean: rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME) ---- Makefile.srcs -+++ Makefile.srcs +--- a/Makefile.srcs ++++ b/Makefile.srcs @@ -1,6 +1,14 @@ +USE_EXR ?= yes +USE_JPEG ?= yes @@ -400,8 +400,8 @@ lots of fixes here: +INCLUDE-$(USE_TIFF) += -DUSE_TIFF $(shell $(PKG_CONFIG) --cflags-only-I libtiff-4 IlmBase) +INCLUDE-$(USE_RAW) += -DUSE_RAW $(shell $(PKG_CONFIG) --cflags-only-I libraw) +INCLUDE = $(INCLUDE-yes) ---- fipMakefile.srcs -+++ fipMakefile.srcs +--- a/fipMakefile.srcs ++++ b/fipMakefile.srcs @@ -1,6 +1,14 @@ +USE_EXR ?= yes +USE_JPEG ?= yes @@ -529,8 +529,8 @@ lots of fixes here: INCLUDE = -I. \ -ISource \ -ISource/Metadata \ ---- Source/FreeImage/PluginRAW.cpp -+++ Source/FreeImage/PluginRAW.cpp +--- a/Source/FreeImage/PluginRAW.cpp ++++ b/Source/FreeImage/PluginRAW.cpp @@ -19,7 +19,7 @@ // Use at your own risk! // ========================================================== @@ -540,8 +540,8 @@ lots of fixes here: #include "FreeImage.h" #include "Utilities.h" ---- Source/Metadata/XTIFF.cpp -+++ Source/Metadata/XTIFF.cpp +--- a/Source/Metadata/XTIFF.cpp ++++ b/Source/Metadata/XTIFF.cpp @@ -29,7 +29,7 @@ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters #endif @@ -551,8 +551,8 @@ lots of fixes here: #include "FreeImage.h" #include "Utilities.h" ---- Source/FreeImage/PluginTIFF.cpp -+++ Source/FreeImage/PluginTIFF.cpp +--- a/Source/FreeImage/PluginTIFF.cpp ++++ b/Source/FreeImage/PluginTIFF.cpp @@ -37,9 +37,9 @@ #include "FreeImage.h" @@ -565,8 +565,8 @@ lots of fixes here: #include "FreeImageIO.h" #include "PSDParser.h" ---- Source/tiffiop.h -+++ Source/tiffiop.h +--- a/Source/tiffiop.h ++++ b/Source/tiffiop.h @@ -30,7 +30,9 @@ * ``Library-private'' definitions. */ @@ -578,8 +578,8 @@ lots of fixes here: #ifdef HAVE_FCNTL_H # include <fcntl.h> ---- Source/FreeImage/Plugin.cpp -+++ Source/FreeImage/Plugin.cpp +--- a/Source/FreeImage/Plugin.cpp ++++ b/Source/FreeImage/Plugin.cpp @@ -223,23 +223,33 @@ */ s_plugins->AddNode(InitBMP); diff --git a/media-libs/freeimage/freeimage-3.15.4-r1.ebuild b/media-libs/freeimage/freeimage-3.15.4-r1.ebuild new file mode 100644 index 000000000000..2b58afe41e4b --- /dev/null +++ b/media-libs/freeimage/freeimage-3.15.4-r1.ebuild @@ -0,0 +1,116 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=6 + +inherit toolchain-funcs eutils + +MY_PN=FreeImage +MY_PV=${PV//.} +MY_P=${MY_PN}${MY_PV} + +DESCRIPTION="Image library supporting many formats" +HOMEPAGE="http://freeimage.sourceforge.net/" +SRC_URI="mirror://sourceforge/${PN}/${MY_P}.zip + mirror://sourceforge/${PN}/${MY_P}.pdf" + +LICENSE="|| ( GPL-2 FIPL-1.0 )" +SLOT="0" +KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux" +IUSE="jpeg jpeg2k mng openexr png raw static-libs tiff" + +# The tiff/ilmbase isn't a typo. The TIFF plugin cheats and +# uses code from it to handle 16bit<->float conversions. +RDEPEND=" + sys-libs/zlib + jpeg? ( virtual/jpeg:0 ) + jpeg2k? ( media-libs/openjpeg:0= ) + mng? ( media-libs/libmng:= ) + openexr? ( media-libs/openexr:= ) + png? ( media-libs/libpng:0= ) + raw? ( media-libs/libraw:= ) + tiff? ( + media-libs/ilmbase:= + media-libs/tiff:0 + )" +DEPEND="${RDEPEND} + virtual/pkgconfig + app-arch/unzip" + +S=${WORKDIR}/${MY_PN} + +DOCS=( "${DISTDIR}"/${MY_P}.pdf README.linux Whatsnew.txt ) +PATCHES=( + "${FILESDIR}"/${PN}-3.15.4-{unbundling,raw}.patch + "${FILESDIR}"/${PN}-3.15.4-CVE-2016-5684-1.patch + "${FILESDIR}"/${PN}-3.15.4-CVE-2016-5684-2.patch + "${FILESDIR}"/${PN}-3.15.4-CVE-2015-0852.patch +) + +src_prepare() { + pushd Source >/dev/null || die + if has_version ">=media-libs/libjpeg-turbo-1.2.1"; then + # Patch from Christian Heimes's fork (thanks) + # https://bitbucket.org/tiran/freeimageturbo + eapply "${FILESDIR}"/${PN}-3.15.4-libjpeg-turbo.patch + cp LibJPEG/{jpegcomp.h,jpegint.h} . || die + fi + cp LibJPEG/{transupp.c,transupp.h,jinclude.h} . || die + cp LibTIFF4/{tiffiop,tif_dir}.h . || die + rm -rf LibPNG LibMNG LibOpenJPEG ZLib OpenEXR LibRawLite LibTIFF4 LibJPEG || die + popd >/dev/null || die + + edos2unix Makefile.{gnu,fip,srcs} fipMakefile.srcs */*.h */*/*.cpp + sed -i \ + -e "s:/./:/:g" \ + -e "s: ./: :g" \ + -e 's: Source: \\\n\tSource:g' \ + -e 's: Wrapper: \\\n\tWrapper:g' \ + -e 's: Examples: \\\n\tExamples:g' \ + -e 's: TestAPI: \\\n\tTestAPI:g' \ + -e 's: -ISource: \\\n\t-ISource:g' \ + -e 's: -IWrapper: \\\n\t-IWrapper:g' \ + Makefile.srcs fipMakefile.srcs || die + sed -i \ + -e "/LibJPEG/d" \ + -e "/LibPNG/d" \ + -e "/LibTIFF/d" \ + -e "/Source\/ZLib/d" \ + -e "/LibOpenJPEG/d" \ + -e "/OpenEXR/d" \ + -e "/LibRawLite/d" \ + -e "/LibMNG/d" \ + Makefile.srcs fipMakefile.srcs || die + + default +} + +foreach_make() { + local m + for m in Makefile.{gnu,fip} ; do + emake -f ${m} \ + USE_EXR=$(usex openexr) \ + USE_JPEG=$(usex jpeg) \ + USE_JPEG2K=$(usex jpeg2k) \ + USE_MNG=$(usex mng) \ + USE_PNG=$(usex png) \ + USE_TIFF=$(usex tiff) \ + USE_RAW=$(usex raw) \ + $(usex static-libs '' STATICLIB=) \ + "$@" + done +} + +src_compile() { + tc-export AR PKG_CONFIG + foreach_make \ + CXX="$(tc-getCXX) -fPIC" \ + CC="$(tc-getCC) -fPIC" \ + ${MY_PN} +} + +src_install() { + foreach_make install DESTDIR="${ED}" INSTALLDIR="${ED%/}"/usr/$(get_libdir) + einstalldocs +} |