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

crash due to narrowing cast in update_ref_and_keys()

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,

      7377
        sz= MY_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
      7378
          ((sel->cond_count*2 + sel->between_count)*m+1);
      7379
        if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
      7380
          DBUG_RETURN(TRUE); /* purecov: inspected */
      

      but sz is uint. When the size is larger than 2³², sz wraps around, key_fields is allocated too small which causes a crash later (esp. with ASAN). See the attached test case.

      Reported by Ben Bidner (Automattic.com Security Team).

      Attachments

        Activity

          People

            serg Sergei Golubchik
            serg Sergei Golubchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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