Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-137

cannot get sql for queries with length >= 0x80

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: Core
    • Labels:
      None

      Description

      modutil_get_SQL uses signed char pointers to determine the query length. When the data is larger than 0x80, this is translated to a negative number, and then converted wrong to the unsigned int that is the length.

      Here is an isolated test case that demonstrates the problem:

      #include <stdio.h>
       
      int main()
      {
        /* simulates the data coming in. packet length should be 0x80 */
        char buf[4] = { 0x80, 0, 0, 0};
       
        char* ptr = buf;
        unsigned  int length;
        length = *ptr;
        printf("length when using signed char*: 0x%x\n", length);
       
        unsigned char* uptr = buf;
        length = *uptr;
        printf("length when using unsigned char*: 0x%x\n", length);
      }

      And the output is:

      $ cc t.c
      $ ./a.out 
      length when using signed char*: 0xffffff80
      length when using unsigned char*: 0x80

      This then tries to allocate nunecessary 4G of memory.

      I will send a PR.

        Attachments

          Activity

            People

            Assignee:
            markus makela markus makela
            Reporter:
            yhager Yuval Hager
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.