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

mysql_get_optionv returns a bad pointer for MYSQL_INIT_COMMAND

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • N/A
    • Documentation
    • None
    • Ubuntu

    Description

      I have a mysql.h supplied by MariaDB and Connector C version = 3.4.0.

      The manual for mysql_get_optionv() https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_get_optionv mentions 18 character values.
      There are two spelling errors: MARIADB_OPT_SSL_FPLIST should be MARIADB_OPT_SSL_FP_LIST and MARIADB_OPT_SSL_PASSPHRASE should be MARIADB_OPT_TLS_PASSPHRASE.
      However, that's not the bug.
      After I correct the spelling, 17 of the 18 character values work, that is, mysql_get_optionv returns what I put in with mysql_options.
      However, MYSQL_INIT_COMMAND does not work, that is, I put in "X" with mysql_options and the result is: mysql_get_optionv does not return an error, the result is not NULL, but it is garbage. This is more important because something is clearly wrong with the pointer and in a larger program I saw a segmentation fault.
      The smallest program example I can make is

      #include <mysql.h>
      #include <stdio.h>
      int main()
      {
        MYSQL *mysql;
        char *text= NULL;
        mysql= mysql_init(NULL);
        if (mysql == NULL) return 1;
        if (mysql_options(mysql, MYSQL_INIT_COMMAND, "X") != 0) return 1;
        if ((mysql_get_optionv(mysql, MYSQL_INIT_COMMAND, &text, NULL) == 0)
         && (text != NULL))
          printf("text MYSQL_INIT_COMMAND=%s.\n", text);
        mysql_close(mysql);
        return 0;
      }
      

      And a sample run is
      pgulutzan@pgulutzan-VirtualBox:~$ ./init_command
      text MYSQL_INIT_COMMAND=p�V.

      Attachments

        Activity

          People

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