Advertisement
buonaseva_fatelo

CVE-2021-30860

Jan 8th, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1.  
  2. enum JBIG2SegmentType
  3. {
  4.     jbig2SegBitmap,
  5.     jbig2SegSymbolDict,
  6.     jbig2SegPatternDict,
  7.     jbig2SegCodeTable
  8. };
  9.  
  10. ////ACID: refSegs, nRefSegs
  11. void JBIG2Stream::readTextRegionSeg(unsigned int segNum, bool imm, bool lossless, unsigned int length, unsigned int *refSegs, unsigned int nRefSegs)
  12. {
  13.     JBIG2Segment *seg;
  14.     std::vector codeTables;
  15.     JBIG2SymbolDict *symbolDict;
  16.     JBIG2Bitmap **syms;
  17.     unsigned int huff;
  18.     unsigned int numSyms, symCodeLen;
  19.     unsigned int i, k, kk;
  20.  
  21.     // ...
  22.  
  23.     // get symbol dictionaries and tables
  24.     numSyms = 0;
  25.     for (i = 0; i < nRefSegs; ++i) {
  26.         if ((seg = findSegment(refSegs[i]))) {
  27.             if (seg->getType() == jbig2SegSymbolDict) {
  28.                 numSyms += ((JBIG2SymbolDict *)seg)->getSize();
  29.             } else if (seg->getType() == jbig2SegCodeTable) {
  30.                 codeTables.push_back(seg);
  31.             }
  32.         } else {
  33.             error(errSyntaxError, curStr->getPos(), "Invalid segment reference in JBIG2 text region");
  34.             return;
  35.         }
  36.     }
  37.  
  38.     // ...
  39.  
  40.     // get the symbol bitmaps
  41.     syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
  42.     if (numSyms > 0 && !syms) {
  43.         return;
  44.     }
  45.     kk = 0;
  46.     for (i = 0; i < nRefSegs; ++i) {
  47.         if ((seg = findSegment(refSegs[i]))) {
  48.             if (seg->getType() == jbig2SegSymbolDict) {
  49.                 symbolDict = (JBIG2SymbolDict *)seg;
  50.                 for (k = 0; k < symbolDict->getSize(); ++k) {
  51.                     syms[kk++] = symbolDict->getBitmap(k);
  52.                 }
  53.             }
  54.         }
  55.     }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement