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

Wrong param parsing in spider_direct_sql() when param contain comma

Details

    Description

      This report id based on actual customer use case.

      Spider fails to parse properly the parameter to two of its UDF when the value of a sub-parameter contains a comma - even when the coma is included in correctly quoted string. With these UDF, "parameter" is actually a string which contains a list of comma-separated names and values for multiple sub-parameters to the SQL statement that will be executed.

      The primary reason seams for the error to be that Spider simply breaks down the parameter string at each comma, not paying attention when the comma is properly quoted (i.e. part of of a sub-parameter value).

      Two Spider UDF functions are affected, spider_bg_direct_sql() and spider_direct_sql, which likely share same parsing code.

      Example - create a database in the backend server with a user whose password contains a comma. Note that the comma in "pass,1234" is part of a quoted string and is not a delimiter.

      SELECT spider_direct_sql('CREATE DATABASE test123', '', 'host "172.16.1.21", port "3306", user "spider", password "pass,1234" , database "test"') from dual;
       
      ERROR 12503 (HY000): The UDF parameter 'password "pass' is invalid
      

      The error message clearly shows that the parameter string has been split by the comma inside the quoted string.

      A possible location of the offending code could be along lines 1160 of spd_direct_sql.cc:

          if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
          {
            *sprit_ptr[1] = '\0';
            sprit_ptr[1]++;
          }
      

      strchr() will simply return the next occurrence of the comma without taking into account the surrounding quotes.

      Attachments

        Activity

          assen.totin Assen Totin (Inactive) created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          Fix Version/s 10.4 [ 22408 ]
          Assignee Kentoku Shiba [ kentoku ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Priority Major [ 3 ] Critical [ 2 ]
          Kentoku Kentoku Shiba (Inactive) made changes -
          Status Open [ 1 ] In Progress [ 3 ]

          Reproduce, investigate, design, fix, test, commit, push to 10.4, 10.5, 10.6

          Kentoku Kentoku Shiba (Inactive) added a comment - Reproduce, investigate, design, fix, test, commit, push to 10.4, 10.5, 10.6
          Kentoku Kentoku Shiba (Inactive) made changes -
          issue.field.resolutiondate 2020-08-18 10:01:54.0 2020-08-18 10:01:54.279
          Kentoku Kentoku Shiba (Inactive) made changes -
          Fix Version/s 10.4.15 [ 24507 ]
          Fix Version/s 10.5.6 [ 24508 ]
          Fix Version/s 10.6.0 [ 24431 ]
          Fix Version/s 10.4 [ 22408 ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 10.5.7 [ 25019 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 10.5.6 [ 24508 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 10.4.16 [ 25020 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 10.4.15 [ 24507 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 100411 ] MariaDB v4 [ 156863 ]

          People

            Kentoku Kentoku Shiba (Inactive)
            assen.totin Assen Totin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.