Conversation
Use the deserialized reason-code view instead of the MQTT 3 fixed offset, which exposes the property length as the first grant and omits the final filter's result. Validate the command type and reason-code count before invoking callbacks. Add eight unit tests for refusals, properties, malformed reason arrays and mismatched commands.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MQTT 5 SUBACK packets include a variable-length properties section between the packet identifier and the per-filter reason codes.
handleAcks()still uses the MQTT 3 offset (pRemainingData[2]), so callbacks receive the property-length byte as the first result and miss the last filter's actual reason code.For example,
90 04 00 01 00 87is a valid single-filter SUBACK reportingNot authorized. The completion callback currently sees0x00(granted QoS 0) instead of0x87. Replies containing properties can expose property bytes as grant codes instead.Use the parser's reason-code view, preserving the existing callback pointer type. Verify that the acknowledged command is a SUBSCRIBE and that the number of reason codes matches the requested filters before exposing the array. Invalid metadata completes the command with
MQTTBadResponseand no reason-code pointer.Eight unit tests cover single and batched refusals, a Reason String property, short/long reason arrays, missing metadata/storage, and a mismatched command type. No public API changes.
Test Steps
Upstream tests were built on macOS with C99, Ruby 2.6, and explicit Clang coverage-runtime linker flags:
Checklist:
Related Issue
None.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.