Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-78

SQLGetData would not return SQL_NO_DATA for BLOB/TEXT columns if the buffer size is larger than the column data.

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.0.13
    • 2.0.14, 3.0.1
    • None
    • None

    Description

      The standard prescribes that SQLGetData() returns SQL_NO_DATA after retrieving the last portion of the column data.
      Currently, the driver does not return that error nor returns it zero length in the indicator (StrLen_or_IndPtr) argument if the whole data can be fetched to the buffer at once.
      The code relying upon the described above behavior may enter an unbound loop reading the (same) data indefinitely (until the process crashes).

      --- ./ma_statement.c.ori        2016-12-05 18:34:45.956616000 -0800
      +++ ./ma_statement.c    2016-12-14 18:25:59.371718000 -0800
      @@ -2607,9 +2607,7 @@
             }
             if (StrLen_or_IndPtr)
               *StrLen_or_IndPtr= *Bind.length - Stmt->CharOffset[Offset];
      -      /* Increase Offset only when the buffer wasn't fetched completely */
      -      if (*Bind.length > (Bind.buffer_length - ZeroTerminated))
      -        Stmt->CharOffset[Offset]+= MIN((unsigned long)BufferLength - ZeroTerminated, *Bind.length);
      +      Stmt->CharOffset[Offset]+= MIN((unsigned long)BufferLength - ZeroTerminated, *Bind.length);
             if ((BufferLength - ZeroTerminated) && Stmt->Lengths[Offset] > Stmt->CharOffset[Offset])
             {
               MADB_SetError(&Stmt->Error, MADB_ERR_01004, NULL, 0);
      

      The behavior triggered by the line ma_statement.c:2566 (Stmt->CharOffset[Offset]= 0;) is also questionable.

      Attachments

        Activity

          yv Yuriy Vasylchenko created issue -

          The fix and the testcase have been pushed(only to odbc-2.0 so far) as rev f185440c17db1f80ac369b4dab54fdbe1487a882

          Lawrin Lawrin Novitsky added a comment - The fix and the testcase have been pushed(only to odbc-2.0 so far) as rev f185440c17db1f80ac369b4dab54fdbe1487a882
          Lawrin Lawrin Novitsky made changes -
          Field Original Value New Value
          Fix Version/s 2.0.14 [ 22510 ]
          Fix Version/s 3.0.1 [ 22511 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB connectors [ 79111 ] MariaDB v3 [ 84046 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 84046 ] MariaDB v4 [ 135423 ]

          People

            Lawrin Lawrin Novitsky
            yv Yuriy Vasylchenko
            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.