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

Binary_string::realloc_raw uint32 overflow on > 4 GB nested string operation

    XMLWordPrintable

Details

    • Bug
    • Status: Needs Feedback (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.3
    • None
    • None
    • None
    • MariaDB 13.3.0-MariaDB-asan-debug, self-built from commit 392818112 with -DWITH_ASAN=ON -DCMAKE_BUILD_TYPE=Debug; Linux x86_64; requires > 4 GB RAM for the intermediate buffer

    Description

      Nested string operations that produce an intermediate exceeding 2^32 bytes crash with an assertion in Binary_string::realloc_raw. On release builds the realloc is skipped (buffer appears big enough due to uint32 wrap) → heap buffer overflow write.

      Reproduce (non-superuser)

      SELECT REGEXP_REPLACE(REPEAT('a', 1073741823), '(.+)', '\\1\\1\\1\\1\\1');

      Actual result

      Assertion 'len > alloc_length' failed in Binary_string::realloc_raw
      sql/sql_string.cc:89

      Root cause

      realloc_raw receives len as size_t but compares it with uint32 alloc_length; the wrapped len is smaller than alloc_length, so the assert fires. On release builds the realloc is skipped and subsequent writes overflow the existing buffer.

      Expected result

      The statement should return an error without crashing.

      Severity assessment

      HIGH — same class as the real_alloc overflow; potential heap OOB write on release builds.

      Attachments

        Issue Links

          Activity

            People

              shipjain Shipra Jain
              imchifan 刘启帆
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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