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

Add a new callback option STMT_ATTR_CB_RESULT_EX

    XMLWordPrintable

Details

    Description

      STMT_ATTR_CB_RESULT lets an application receive the raw binary-protocol data of each column instead of having C/C fill a bind buffer. The callback gets a pointer to the current position in the row (unsigned char **row) but no information about where the row data ends. A callback therefore cannot validate the data it parses. Length-encoded values (net_field_length), fixed-size integers and floats, and temporal values are all read without any way to check that enough bytes remain. Connector/Python’s callback is one example of an implementation that cannot be made memory-safe with the current API.

      Problem

      The callback parses data supplied by the server. With a truncated or malformed row, for example a length-encoded prefix announcing more bytes than the packet contains, or a DATETIME with an invalid length byte, the callback reads past the end of the buffer. The result is an out-of-bounds read: potential information disclosure or a crash in the client process. Applications cannot work around this, because the packet boundary is not part of the public API and relying on internal structures is not viable.

      Proposed solution

      Add a new statement attribute, STMT_ATTR_CB_RESULT_EX, with a callback type that includes an end pointer and a return value:

      Attachments

        Issue Links

          Activity

            People

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