Uploaded image for project: 'OASIS Message Queuing Telemetry Transport (MQTT) TC'
  1. OASIS Message Queuing Telemetry Transport (MQTT) TC
  2. MQTT-296

Variable Byte Integer decode does not check for shortest encoding

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      The algorithm shown for decoding a Variable Byte Integer (section 1.5.5) does not check for non-minimal length encodings. For instance the byte sequence 0x80,0x80,0x80,0x01 would decode the value 1 even though this encoding does not match the requirements in the normative text.

      If we mean to allow non-minimal length encodings of Variable Byte Integer then we should say so, otherwise we should clearly state the only the minimum length encoding is allowed, and change the decode algorithm to detect this and throw an error.

        Attachments

          Activity

          Hide
          edbriggs Ed Briggs [X] (Inactive) added a comment -

          I fully agree that the standard should say the minimum encoding size must be used. However I don't see the need to throw an error or disconnect since the correct value will be retrieved in either case. The performance penalty for non-minimum encoding is just a co9uple of bytes. Just a thought.

          Show
          edbriggs Ed Briggs [X] (Inactive) added a comment - I fully agree that the standard should say the minimum encoding size must be used. However I don't see the need to throw an error or disconnect since the correct value will be retrieved in either case. The performance penalty for non-minimum encoding is just a co9uple of bytes. Just a thought.
          Hide
          ken.borgendale Ken Borgendale (Inactive) added a comment -

          It is actually a pretty simple check that the first byte of the Variable Byte Integer is not 0x80.

          It would be fine with me to say the sender MUST use the minimum length encoding, which then implies that the receiver MAY check it. I think the current text implies this but it would be better to spell this out explicitly. In V3.1.1 our tendency was to require that the receiver check most things so this is a bit of an anomaly.

          Show
          ken.borgendale Ken Borgendale (Inactive) added a comment - It is actually a pretty simple check that the first byte of the Variable Byte Integer is not 0x80. It would be fine with me to say the sender MUST use the minimum length encoding, which then implies that the receiver MAY check it. I think the current text implies this but it would be better to spell this out explicitly. In V3.1.1 our tendency was to require that the receiver check most things so this is a bit of an anomaly.
          Hide
          ken.borgendale Ken Borgendale (Inactive) added a comment -

          Issue included in MQTTv5.0 CS01 December 25, 2017

          Show
          ken.borgendale Ken Borgendale (Inactive) added a comment - Issue included in MQTTv5.0 CS01 December 25, 2017

            People

            • Assignee:
              edbriggs Ed Briggs [X] (Inactive)
              Reporter:
              ken.borgendale Ken Borgendale (Inactive)
            • Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: