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

uninited var can be read in gtid_delete_pending()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4.1
    • 10.4.5
    • Replication
    • None

    Description

      marko reports

      gcc 8 -O2 seems to indicate a real error for this code:
          table_opened= true;
          table= tlist.table;
       
          if ((err= gtid_check_rpl_slave_state_table(table)))
            goto end;
       
          direct_pos= table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION;
      

      the warning:
      /mariadb/10.4/sql/rpl_gtid.cc:980:7: warning: 'direct_pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
      if (!direct_pos)
      ^~
      that code in question is after end:, and inside if (table_opened) (which has been initialized above, but direct_pos is not if we do the above goto end)

      The following patch should suffice:

      diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
      index 17f474c2acf..ab74ab74687 100644
      --- a/sql/rpl_gtid.cc
      +++ b/sql/rpl_gtid.cc
      @@ -904,9 +904,6 @@ rpl_slave_state::gtid_delete_pending(THD *thd,
           table_opened= true;
           table= tlist.table;
       
      -    if ((err= gtid_check_rpl_slave_state_table(table)))
      -      goto end;
      -
           direct_pos= table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION;
           bitmap_set_all(table->write_set);
           table->rpl_write_set= table->write_set;
      @@ -921,6 +918,9 @@ rpl_slave_state::gtid_delete_pending(THD *thd,
             goto end;
           }
       
      +    if ((err= gtid_check_rpl_slave_state_table(table)))
      +      goto end;
      +
           cur = *list_ptr;
           cur_ptr_ptr = list_ptr;
           do
      

      as there's no urgency to call gtid_check_rpl_slave_state_table() earlier than the var-in-question gets assigned.

      Attachments

        Activity

          People

            sujatha.sivakumar Sujatha Sivakumar (Inactive)
            Elkin Andrei Elkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.