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

New API function: mariadb_net_field_length

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.3, 3.4
    • 3.3.22, 3.4.12
    • API
    • None

    Description

      mysql_net_field_length() is a public function that decodes length-encoded integers from raw protocol data. It has no way to know where the buffer ends, so it cannot reject truncated or invalid input. Connectors that parse raw row data, for example in a STMT_ATTR_CB_RESULT_EX callback (CONC-860), have no bounds-checked decoder available and each have to write their own.

      Proposed API

      int STDCALL mariadb_net_field_length(unsigned char **pos,
                                           const unsigned char *end,
                                           unsigned int flags,
                                           unsigned long long *len);
      

      *
      Parameters:*

      • pos: in/out. Start of the length-encoded integer. Advanced past the prefix on MARIADB_LENENC_OK and MARIADB_LENENC_NULL. Unchanged on error.
      • end: first byte after the valid buffer. Never read.
      • flags: 0 or MARIADB_LENENC_FORBID_NULL. Unknown flag bits return MARIADB_LENENC_ERROR.
      • len: out. Decoded 64-bit value. Set to 0 for MARIADB_LENENC_NULL. Unchanged on error.

      Return values (macros in a public header):

      #define MARIADB_LENENC_OK     0  /* length decoded, *pos advanced */
      #define MARIADB_LENENC_NULL   1  /* 0xFB with MARIADB_LENENC_TEXT, *pos advanced by 1 */
      #define MARIADB_LENENC_ERROR  2  /* truncated or invalid prefix, nothing changed */
      

      Attachments

        Issue Links

          Activity

            People

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