Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-932

Login packet has wrong length information for the attributes

Details

    Description

      The latest connector J releases seem have a regression that will set the total length of the attributes part to a very big value, in my test, it was set to 0x FD C4 00 0C, which is 201326788 bytes, but actually it was only about 200 bytes in total. Old releases don't suffer from this issue.

      It can be easily seen with a Wireshark net capture, which will annotates the login packet as malformed, see the network capture result attached.

      Attachments

        Activity

          diego dupin Diego Dupin added a comment -

          I've reproduced that problem.
          It would seems it's an error in wireshark mysql packet decoding.
          0xfdc40000 => byte 0xfd indicate that length is 3 bytes little endian encoded 0xc40000 = 196
          problem is that wireshark use 4 bytes:
          0xc400000c => 201326788

          diego dupin Diego Dupin added a comment - I've reproduced that problem. It would seems it's an error in wireshark mysql packet decoding. 0xfdc40000 => byte 0xfd indicate that length is 3 bytes little endian encoded 0xc40000 = 196 problem is that wireshark use 4 bytes: 0xc400000c => 201326788
          diego dupin Diego Dupin added a comment - - edited wireshark PR submitted ( https://gitlab.com/wireshark/wireshark/-/merge_requests/6239 )
          ThomasDai Thomas Dai added a comment -

          Hi Diego, I think it is also something not expected that using 3 bytes to encode an integer when 1 byte is enough? Quoting the MySQL's document here (link: https://dev.mysql.com/doc/internals/en/integer.html):

          "An integer that consumes 1, 3, 4, or 9 bytes, depending on its numeric value
          To convert a number value into a length-encoded integer:
          If the value is < 251, it is stored as a 1-byte integer."

          This may break some system that adheres strictly to the above rules. It is possible to fix this on the connector side, too? seems only the new releases suffer from this issue...

          ThomasDai Thomas Dai added a comment - Hi Diego, I think it is also something not expected that using 3 bytes to encode an integer when 1 byte is enough? Quoting the MySQL's document here (link: https://dev.mysql.com/doc/internals/en/integer.html): "An integer that consumes 1, 3, 4, or 9 bytes, depending on its numeric value To convert a number value into a length-encoded integer: If the value is < 251, it is stored as a 1-byte integer." This may break some system that adheres strictly to the above rules. It is possible to fix this on the connector side, too? seems only the new releases suffer from this issue...
          diego dupin Diego Dupin added a comment -

          I asked myself this question during the implementation and this trick permit some optimization, but allright, predictability/ensure compatibility is a better argument.
          It will be part of 3.0.4 release

          diego dupin Diego Dupin added a comment - I asked myself this question during the implementation and this trick permit some optimization, but allright, predictability/ensure compatibility is a better argument. It will be part of 3.0.4 release
          ThomasDai Thomas Dai added a comment -

          Thanks Diego!

          ThomasDai Thomas Dai added a comment - Thanks Diego!

          People

            diego dupin Diego Dupin
            ThomasDai Thomas Dai
            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.