Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2189

XMLChar with NEED_TO_GEN_TABLE has 2 buffer out of bounds reads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.2
    • 3.2.3
    • Utilities
    • None

    Description

      During scan with cppcheck 1.90, the XMLChar's code under #ifdef NEED_TO_GEN_TABLE has two out-of-bounds reads in initCharFlagTable() and in initCharFlagTable1_1():

      fprintf(outFl, "XMLByte ...[0x10000] =\n{");
      for (unsigned int index = 0; index <= 0xFFFF; index += 16)

      { fprintf(... , (unsigned int)gTmpCharTable[index] ... , (unsigned int)gTmpCharTable[index+15]); }

      fprintf(outFl, "};\n");

       

      But the gTmpCharTable's size is 0xffff (which is 1 less than 0x10000), and at the last loop, when index==0xFFF0, we access gTmpCharTable[0xFFF0+15] which is gTmpCharTable[0xFFFF], which is 1 after the end of buffer.

       

      I'd say that gTmpCharTable shall have 0x10000 elements, and not 0xFFFF...

       

      Attachments

        Activity

          People

            scantor Scott Cantor
            alexeyroytman Alexey Roytman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: