Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-5389

MQTTCodec headerParser - not reducing readSize if nulls are read

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.11.0
    • 5.11.0
    • MQTT
    • None

    Description

      in the header read you'll notice that if 0's are read, i increases to protect the end of buffer, but when you pass this down to the next parser the size of the buffer passed is readSize-1 not readSize-i
      As well there is a check for readsize > 1.. this should be (readsize-i > 1)

      @Override
              public void parse(DataByteArrayInputStream data, int readSize) throws IOException {
                  int i = 0;
                  while (i++ < readSize) {
                      byte b = data.readByte();
                      // skip repeating nulls
                      if (b == 0) {
                          continue;
                      }
      
                      header = b;
      
                      currentParser = initializeVariableLengthParser();
      
                      // if (readSize > 1) {
                      //     currentParser.parse(data, readSize - 1);
                      if (readSize-i > 1) {
                          currentParser.parse(data, readSize - i);
      
                      }
                      return;
                  }
              }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tabish Timothy A. Bish
            cjutzi Curt Jutzi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment