• unknown's avatar
    Bug#23139 - myisamchk and mysqld crash when trying to access table · 12db2f95
    unknown authored
    A corrupted compressed table could crash the server and
    myisamchk.
    
    The data file of an uncompressed table contains just the records.
    There is no header in the data file.
    
    However the data file of a compressed table has a header.
    The header describes how the table was compressed. This
    information is necessary to extract the records from the
    compressed data file.
    
    Part of the compressed data file header are the [de]code tables.
    They are numeric representations of the Huffman trees used for
    coding and decoding. A Huffman tree is a binary tree. Every
    node has two childs. A child can be a leaf or a branch. Leaves
    contain the decoded value. Branches point to another tree node.
    
    Since the [de]code table is represented as an array of childs,
    the branches need to point at a child within the same array.
    The corruption of the compressed data file from the bug report
    was a couple of branches that pointed outside their array.
    This condition had not been correctly checked.
    
    I added some checks for the pointers in the decode tables.
    This type of corruption will no longer crash the server or
    myisamchk.
    
    No test case. A corrupted compressed table is required.
    
    
    myisam/mi_packrec.c:
      Bug#23139 - myisamchk and mysqld crash when trying to access table
      Added some checks for the pointers in the decode tables.
      Added comments, DBUG prints, style fixes.
    12db2f95
mi_packrec.c 48.3 KB