Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40924

Validate insert_length before memcpy in KEY_OP_ADD_SUFFIX

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      Fixes unchecked memcpy in Aria redo log apply.

      Bug: KEY_OP_ADD_SUFFIX at ma_key_recover.c:1058 does memcpy with insert_length only guarded by DBUG_ASSERT, no runtime check for header_end or max_page_size. Corrupt log can cause heap overflow. DEL_SUFFIX has same missing runtime check.

      Fix: Add runtime validation before memcpy and page_length update. For ADD_SUFFIX verify header+2+insert_length <= header_end and page_length+insert_length <= max_page_size, for DEL_SUFFIX verify header <= header_end and page_length >= keypage_header+del_length. On failure set mark_crashed=1 and goto err to mark file crashed. Keeps existing DBUG_ASSERT for debug builds.

      Evidence: Verified RED has no runtime check, GREEN adds bounds checks. Diff touches 1 file, 12 lines.

      Attachments

        Activity

          People

            monty Michael Widenius
            gkodinov Georgi Kodinov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Remaining Estimate - 0.5d
                0.5d
                Logged:
                Time Spent - Not Specified
                Not Specified

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.