~ubuntu-branches/ubuntu/saucy/libjpeg-turbo/saucy-security

« back to all changes in this revision

Viewing changes to jccolor.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose, Tom Gall, Matthias Klose
  • Date: 2012-09-20 00:18:15 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120920001815-eijk7v63d1nv0vbo
Tags: 1.2.1-0ubuntu1
[ Tom Gall ]
* Update to stable 1.2.1. LP: #1012861.
  * Addresses CVE-2012-2806. LP: #1025537.
    A Heap-based buffer overflow was found in the way libjpeg-turbo
    decompressed certain corrupt JPEG images in which the component count
    was erroneously set to a large value. An attacker could create a
    specially-crafted JPEG image that, when opened, could cause an
    application using libpng to crash or, possibly, execute arbitrary code
    with the privileges of the user running the application.
  * Cosmetic fixes to argument lists
  * Added flags to the TurboJPEG API that allow the caller to force
    the use of either the fast or the accurate DCT/IDCT algorithms
    in the underlying codec.
  * More recent versions of autoconf add -traditional-cpp to the CPP
    flags, which causes jsimdcfg.inc.h to not preprocess correctly
    unless we expand all of the instances of the #definev macro.
  * Fixed regression caused by a bug in the 32-bit strict memory access
    code in jdmrgss2.asm (contributed by Chromium to stop valgrind from
    whining whenever the output buffer size was not evenly divisible by
    16 bytes.)  On Linux/x86, this regression generated incorrect
    pixels on the right-hand side of images whose rows were not 16-byte
    aligned, whenever fancy upsampling was used.  This patch also
    enables the strict memory access code on all platforms, not just
    Linux (it does no harm on other platforms) and removes a couple of
    pcmpeqb instructions that were rendered unnecessary by r835.
  * Accelerated 4:2:2 upsampling routine for ARM (improves
    performance ~20-30% when decompressing 4:2:2 JPEGs using
    fancy upsampling)
  * Eliminate the use of the MASKMOVDQU instruction, to speed
    up decompression performance by 10x on AMD Bobcat embedded
    processors (and ~5% on AMD desktop processors.)
  * add tjbench to libjpeg-turbo-test packages
  * Guard against num_components being a ridiculous
    value due to a corrupt header
  * Preserve all 128 bits of xmm6 and xmm7

[ Matthias Klose ]
* Prepare the package for quantal, basing on the 1.2.1 release tarball.
* d/patches/branch-updates.diff: Update to 20120919 of the 1.2.x branch,
  but don't bump the version to 1.2.2.
* d/patches/guard-inline-define: Remove, integrated upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Copyright (C) 1991-1996, Thomas G. Lane.
5
5
 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
6
 
 * Copyright (C) 2009-2011, D. R. Commander.
 
6
 * Copyright (C) 2009-2012, D. R. Commander.
7
7
 * This file is part of the Independent JPEG Group's software.
8
8
 * For conditions of distribution and use, see the accompanying README file.
9
9
 *
14
14
#include "jinclude.h"
15
15
#include "jpeglib.h"
16
16
#include "jsimd.h"
 
17
#include "config.h"
17
18
 
18
19
 
19
20
/* Private subobject */
95
96
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
96
97
#define rgb_ycc_convert_internal extrgb_ycc_convert_internal
97
98
#define rgb_gray_convert_internal extrgb_gray_convert_internal
 
99
#define rgb_rgb_convert_internal extrgb_rgb_convert_internal
98
100
#include "jccolext.c"
99
101
#undef RGB_RED
100
102
#undef RGB_GREEN
102
104
#undef RGB_PIXELSIZE
103
105
#undef rgb_ycc_convert_internal
104
106
#undef rgb_gray_convert_internal
 
107
#undef rgb_rgb_convert_internal
105
108
 
106
109
#define RGB_RED EXT_RGBX_RED
107
110
#define RGB_GREEN EXT_RGBX_GREEN
109
112
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
110
113
#define rgb_ycc_convert_internal extrgbx_ycc_convert_internal
111
114
#define rgb_gray_convert_internal extrgbx_gray_convert_internal
 
115
#define rgb_rgb_convert_internal extrgbx_rgb_convert_internal
112
116
#include "jccolext.c"
113
117
#undef RGB_RED
114
118
#undef RGB_GREEN
116
120
#undef RGB_PIXELSIZE
117
121
#undef rgb_ycc_convert_internal
118
122
#undef rgb_gray_convert_internal
 
123
#undef rgb_rgb_convert_internal
119
124
 
120
125
#define RGB_RED EXT_BGR_RED
121
126
#define RGB_GREEN EXT_BGR_GREEN
123
128
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
124
129
#define rgb_ycc_convert_internal extbgr_ycc_convert_internal
125
130
#define rgb_gray_convert_internal extbgr_gray_convert_internal
 
131
#define rgb_rgb_convert_internal extbgr_rgb_convert_internal
126
132
#include "jccolext.c"
127
133
#undef RGB_RED
128
134
#undef RGB_GREEN
130
136
#undef RGB_PIXELSIZE
131
137
#undef rgb_ycc_convert_internal
132
138
#undef rgb_gray_convert_internal
 
139
#undef rgb_rgb_convert_internal
133
140
 
134
141
#define RGB_RED EXT_BGRX_RED
135
142
#define RGB_GREEN EXT_BGRX_GREEN
137
144
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
138
145
#define rgb_ycc_convert_internal extbgrx_ycc_convert_internal
139
146
#define rgb_gray_convert_internal extbgrx_gray_convert_internal
 
147
#define rgb_rgb_convert_internal extbgrx_rgb_convert_internal
140
148
#include "jccolext.c"
141
149
#undef RGB_RED
142
150
#undef RGB_GREEN
144
152
#undef RGB_PIXELSIZE
145
153
#undef rgb_ycc_convert_internal
146
154
#undef rgb_gray_convert_internal
 
155
#undef rgb_rgb_convert_internal
147
156
 
148
157
#define RGB_RED EXT_XBGR_RED
149
158
#define RGB_GREEN EXT_XBGR_GREEN
151
160
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
152
161
#define rgb_ycc_convert_internal extxbgr_ycc_convert_internal
153
162
#define rgb_gray_convert_internal extxbgr_gray_convert_internal
 
163
#define rgb_rgb_convert_internal extxbgr_rgb_convert_internal
154
164
#include "jccolext.c"
155
165
#undef RGB_RED
156
166
#undef RGB_GREEN
158
168
#undef RGB_PIXELSIZE
159
169
#undef rgb_ycc_convert_internal
160
170
#undef rgb_gray_convert_internal
 
171
#undef rgb_rgb_convert_internal
161
172
 
162
173
#define RGB_RED EXT_XRGB_RED
163
174
#define RGB_GREEN EXT_XRGB_GREEN
165
176
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
166
177
#define rgb_ycc_convert_internal extxrgb_ycc_convert_internal
167
178
#define rgb_gray_convert_internal extxrgb_gray_convert_internal
 
179
#define rgb_rgb_convert_internal extxrgb_rgb_convert_internal
168
180
#include "jccolext.c"
169
181
#undef RGB_RED
170
182
#undef RGB_GREEN
172
184
#undef RGB_PIXELSIZE
173
185
#undef rgb_ycc_convert_internal
174
186
#undef rgb_gray_convert_internal
 
187
#undef rgb_rgb_convert_internal
175
188
 
176
189
 
177
190
/*
306
319
 
307
320
 
308
321
/*
 
322
 * Extended RGB to plain RGB conversion
 
323
 */
 
324
 
 
325
METHODDEF(void)
 
326
rgb_rgb_convert (j_compress_ptr cinfo,
 
327
                  JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
 
328
                  JDIMENSION output_row, int num_rows)
 
329
{
 
330
  switch (cinfo->in_color_space) {
 
331
    case JCS_EXT_RGB:
 
332
      extrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
333
                                  num_rows);
 
334
      break;
 
335
    case JCS_EXT_RGBX:
 
336
    case JCS_EXT_RGBA:
 
337
      extrgbx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
338
                                   num_rows);
 
339
      break;
 
340
    case JCS_EXT_BGR:
 
341
      extbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
342
                                  num_rows);
 
343
      break;
 
344
    case JCS_EXT_BGRX:
 
345
    case JCS_EXT_BGRA:
 
346
      extbgrx_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
347
                                   num_rows);
 
348
      break;
 
349
    case JCS_EXT_XBGR:
 
350
    case JCS_EXT_ABGR:
 
351
      extxbgr_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
352
                                   num_rows);
 
353
      break;
 
354
    case JCS_EXT_XRGB:
 
355
    case JCS_EXT_ARGB:
 
356
      extxrgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
357
                                   num_rows);
 
358
      break;
 
359
    default:
 
360
      rgb_rgb_convert_internal(cinfo, input_buf, output_buf, output_row,
 
361
                               num_rows);
 
362
      break;
 
363
  }
 
364
}
 
365
 
 
366
 
 
367
/*
309
368
 * Convert some rows of samples to the JPEG colorspace.
310
369
 * This version handles Adobe-style CMYK->YCCK conversion,
311
370
 * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
522
581
    break;
523
582
 
524
583
  case JCS_RGB:
525
 
  case JCS_EXT_RGB:
526
 
  case JCS_EXT_RGBX:
527
 
  case JCS_EXT_BGR:
528
 
  case JCS_EXT_BGRX:
529
 
  case JCS_EXT_XBGR:
530
 
  case JCS_EXT_XRGB:
531
 
  case JCS_EXT_RGBA:
532
 
  case JCS_EXT_BGRA:
533
 
  case JCS_EXT_ABGR:
534
 
  case JCS_EXT_ARGB:
535
584
    if (cinfo->num_components != 3)
536
585
      ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
537
 
    if (cinfo->in_color_space == cinfo->jpeg_color_space &&
538
 
      rgb_pixelsize[cinfo->in_color_space] == 3)
 
586
    if (rgb_red[cinfo->in_color_space] == 0 &&
 
587
        rgb_green[cinfo->in_color_space] == 1 &&
 
588
        rgb_blue[cinfo->in_color_space] == 2 &&
 
589
        rgb_pixelsize[cinfo->in_color_space] == 3)
539
590
      cconvert->pub.color_convert = null_convert;
 
591
    else if (cinfo->in_color_space == JCS_RGB ||
 
592
             cinfo->in_color_space == JCS_EXT_RGB ||
 
593
             cinfo->in_color_space == JCS_EXT_RGBX ||
 
594
             cinfo->in_color_space == JCS_EXT_BGR ||
 
595
             cinfo->in_color_space == JCS_EXT_BGRX ||
 
596
             cinfo->in_color_space == JCS_EXT_XBGR ||
 
597
             cinfo->in_color_space == JCS_EXT_XRGB ||
 
598
             cinfo->in_color_space == JCS_EXT_RGBA ||
 
599
             cinfo->in_color_space == JCS_EXT_BGRA ||
 
600
             cinfo->in_color_space == JCS_EXT_ABGR ||
 
601
             cinfo->in_color_space == JCS_EXT_ARGB)
 
602
      cconvert->pub.color_convert = rgb_rgb_convert;
540
603
    else
541
604
      ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
542
605
    break;