View | Details | Raw Unified | Return to bug 137156
Collapse All | Expand All

(-)JBIG2Stream.cc (-4 / +29 lines)
Lines 7-12 Link Here
7
//========================================================================
7
//========================================================================
8
8
9
#include <aconf.h>
9
#include <aconf.h>
10
#include <limits.h>
10
11
11
#ifdef USE_GCC_PRAGMAS
12
#ifdef USE_GCC_PRAGMAS
12
#pragma implementation
13
#pragma implementation
Lines 681-689 JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, Link Here
681
  w = wA;
682
  w = wA;
682
  h = hA;
683
  h = hA;
683
  line = (wA + 7) >> 3;
684
  line = (wA + 7) >> 3;
684
  // need to allocate one extra guard byte for use in combine()
685
685
  data = (Guchar *)gmalloc(h * line + 1);
686
  if (h < 0 || line <= 0 || h >= INT_MAX / line) {
686
  data[h * line] = 0;
687
    data = NULL;
688
  }
689
  else {
690
    // need to allocate one extra guard byte for use in combine()
691
    data = (Guchar *)gmalloc(h * line + 1);
692
    data[h * line] = 0;
693
  }
687
}
694
}
688
695
689
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap):
696
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap):
Lines 692-697 JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, Link Here
692
  w = bitmap->w;
699
  w = bitmap->w;
693
  h = bitmap->h;
700
  h = bitmap->h;
694
  line = bitmap->line;
701
  line = bitmap->line;
702
703
  if (h < 0 || line <= 0 || h >= INT_MAX / line) {
704
    data = NULL;
705
    return;
706
  }
707
 
695
  // need to allocate one extra guard byte for use in combine()
708
  // need to allocate one extra guard byte for use in combine()
696
  data = (Guchar *)gmalloc(h * line + 1);
709
  data = (Guchar *)gmalloc(h * line + 1);
697
  memcpy(data, bitmap->data, h * line);
710
  memcpy(data, bitmap->data, h * line);
Lines 720-726 JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint Link Here
720
}
733
}
721
734
722
void JBIG2Bitmap::expand(int newH, Guint pixel) {
735
void JBIG2Bitmap::expand(int newH, Guint pixel) {
723
  if (newH <= h) {
736
  if (newH <= h || line <= 0 || newH >= INT_MAX / line) {
724
    return;
737
    return;
725
  }
738
  }
726
  // need to allocate one extra guard byte for use in combine()
739
  // need to allocate one extra guard byte for use in combine()
Lines 2305-2310 void JBIG2Stream::readHalftoneRegionSeg( Link Here
2305
    error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
2318
    error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
2306
    return;
2319
    return;
2307
  }
2320
  }
2321
  if (gridH == 0 || gridW >= INT_MAX / gridH) {
2322
    error(getPos(), "Bad size in JBIG2 halftone segment");
2323
    return;
2324
  }
2325
  if (w == 0 || h >= INT_MAX / w) {
2326
     error(getPos(), "Bad size in JBIG2 bitmap segment");
2327
    return;
2328
  }
2329
2308
  patternDict = (JBIG2PatternDict *)seg;
2330
  patternDict = (JBIG2PatternDict *)seg;
2309
  bpp = 0;
2331
  bpp = 0;
2310
  i = 1;
2332
  i = 1;
Lines 2936-2941 JBIG2Bitmap *JBIG2Stream::readGenericRef Link Here
2936
  JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2;
2958
  JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2;
2937
  int x, y, pix;
2959
  int x, y, pix;
2938
2960
2961
  if (w < 0 || h <= 0 || w >= INT_MAX / h)
2962
    return NULL;
2963
2939
  bitmap = new JBIG2Bitmap(0, w, h);
2964
  bitmap = new JBIG2Bitmap(0, w, h);
2940
  bitmap->clearToZero();
2965
  bitmap->clearToZero();
2941
2966
(-)Stream.cc (-3 / +3 lines)
Lines 1277-1283 CCITTFaxStream::CCITTFaxStream(Stream *s Link Here
1277
  endOfLine = endOfLineA;
1277
  endOfLine = endOfLineA;
1278
  byteAlign = byteAlignA;
1278
  byteAlign = byteAlignA;
1279
  columns = columnsA;
1279
  columns = columnsA;
1280
  if (columns < 1) {
1280
  if (columns + 3 < 1 || columns + 4 < 1 || columns < 1) {
1281
    columns = 1;
1281
    columns = 1;
1282
  }
1282
  }
1283
  rows = rowsA;
1283
  rows = rowsA;
Lines 3066-3077 GBool DCTStream::readHuffmanTables() { Link Here
3066
  while (length > 0) {
3066
  while (length > 0) {
3067
    index = str->getChar();
3067
    index = str->getChar();
3068
    --length;
3068
    --length;
3069
    if ((index & 0x0f) >= 4) {
3069
    if ((index & ~0x10) >= 4 || (index & ~0x10) < 0) {
3070
      error(getPos(), "Bad DCT Huffman table");
3070
      error(getPos(), "Bad DCT Huffman table");
3071
      return gFalse;
3071
      return gFalse;
3072
    }
3072
    }
3073
    if (index & 0x10) {
3073
    if (index & 0x10) {
3074
      index &= 0x0f;
3074
      index &= 0x03;
3075
      if (index >= numACHuffTables)
3075
      if (index >= numACHuffTables)
3076
	numACHuffTables = index+1;
3076
	numACHuffTables = index+1;
3077
      tbl = &acHuffTables[index];
3077
      tbl = &acHuffTables[index];

Return to bug 137156