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

my_b_write_quoted() doesn't escape single quote and slash which breaks formatting

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
    • 10.4, 10.5, 10.6
    • None
    • None

    Description

      sql/log_event_client.cc (in older versions it is sql/log_event.cc)

      The first test in the if/else block in the for loop looks for chars > 0x1f, but ' and \ are both > 0x1f, so the specialized output for them never gets used.

      if (*s > 0x1F)
            my_b_write_byte(file, *s);
      else if (*s == '\'')
            my_b_write(file, (uchar*)"\\'", 2);
      else if (*s == '\\')
            my_b_write(file, (uchar*)"\\\\", 2);
      

      Please consider changing to:

      if (*s == '\'')
          my_b_write(file, (uchar*)"\\'", 2);
      else if (*s == '\\')
          my_b_write(file, (uchar*)"\\\\", 2);
      else if (isprint(*s))
          my_b_write_byte(file, *s);
      

      Using of isprint() function would also cover some special cases.

      Attachments

        Activity

          People

            Unassigned Unassigned
            yury.chaikou Yury Chaikou
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.