Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-819

mysql_real_escape_string incorrectly handles big5

    XMLWordPrintable

Details

    Description

      test case for unittest/libmariadb/charset.c

      #define TEST_BUG8378a_IN  "\xa1' + 10 -- "
      #define TEST_BUG8378a_OUT "\\\xa1\\' + 10 -- "
       
      /* set connection options */
      struct my_option_st opt_bug8378a[] = {
        {MYSQL_SET_CHARSET_NAME, (char *) "big5"},
        {0, NULL}
      };
       
      int bug_8378a(MYSQL *mysql) {
        int rc, len;
        char out[128], buf[256];
        MYSQL_RES *res;
        MYSQL_ROW row;
       
        /* MXS-4898: MaxScale sends utf8mb4 in handshake OK packet */
        SKIP_MAXSCALE;
       
        len= mysql_real_escape_string(mysql, out, TEST_BUG8378a_IN, sizeof(TEST_BUG8378a_IN)-1);
        FAIL_IF(memcmp(out, TEST_BUG8378a_OUT, len), "wrong result");
       
        sprintf(buf, "SELECT '%s' FROM DUAL", out);
       
        rc= mysql_query(mysql, buf);
        check_mysql_rc(rc, mysql);
       
        if ((res= mysql_store_result(mysql))) {
          row= mysql_fetch_row(res);
          if (memcmp(row[0], TEST_BUG8378a_IN, sizeof(TEST_BUG8378a_IN)-1)) {
            mysql_free_result(res);
            return FAIL;
          }
          mysql_free_result(res);
        } else
          return FAIL;
       
        return OK;
      }
      

      Reported by Jun Rong

      Attachments

        Issue Links

          Activity

            People

              georg Georg Richter
              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.