Skip to content

MQTT-SN fixes#550

Merged
dgarske merged 23 commits into
wolfSSL:masterfrom
embhorn:mqtt-sn-fixes
Jun 10, 2026
Merged

MQTT-SN fixes#550
dgarske merged 23 commits into
wolfSSL:masterfrom
embhorn:mqtt-sn-fixes

Conversation

@embhorn

@embhorn embhorn commented Jun 2, 2026

Copy link
Copy Markdown
Member
  • Fixes from issues reported by user.
    Contribution provided by Javid (GitHub: jmestwa-coder)
  • Fix f-5501 MQTT-SN CONNACK
  • Fix f-3388 SN with MT & NB
  • Add tests for f-5864
  • Fix f-3137 harden SN_WillMessage
  • Fix f-3138 harden SN_Client_WillMsgUpdate
  • Fix f-2756 SN_Client_Subscribe false return code
  • Fix f-3132 SN_Client_Ping with null
  • Fix f-4518 SN_Client_HandlePacket type issue in debug
  • Fix f-5510: MQTT-SN publish encoder harden
  • Fix f-4659: topic_type check in SN_Decode_Publish
  • Fix f-4248: SN_Decode_Publish validate packet_id with QoS>0
  • Fix f-2332: SN_Encode_Subscribe/Unsubscribe check topicNameId
  • Fix f-4058: SN_Decode_Header check buf_len
  • Fix f-3632: Add tests for SN_Decode_GWInfo
  • Fix f-2333 and f-2334: SN_Encode_WillTopic/Update check willTopic
  • Fix f-2330: SN_Encode_Register check topicName
  • Fix f-3831: SN_Decode_Register bounds check rejects all valid REGISTER packets
  • Fix f-5663: example use of sn_reg_callback
  • Fix f-5664: Check payload in sn_message_cb
  • Fix f-5146: publish task testing

@embhorn embhorn self-assigned this Jun 2, 2026
Copilot AI review requested due to automatic review settings June 2, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens MQTT-SN packet handling (especially CONNACK) by adding stricter length/bounds validation in MQTT-SN decoders and ensuring the client path uses the dedicated CONNACK decoder instead of trusting the last byte. It also introduces a standalone unit test binary that regression-tests these decoder guards.

Changes:

  • Fix MQTT-SN CONNACK handling to decode/validate via SN_Decode_ConnectAck rather than reading rx_buf[buf_len-1].
  • Add additional declared-length lower-bound checks in SN_Decode_Header, SN_Decode_GWInfo, and SN_Decode_Register to prevent over-reads/underflows.
  • Add a new tests/test_mqtt_sn decoder-focused unit test program (wired into Automake) plus .gitignore entry.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_mqtt_sn.c New standalone unit tests that construct MQTT-SN frames to validate decoder bounds checks and CONNACK behavior.
tests/include.am Adds Automake rules to build/run the new tests/test_mqtt_sn program when BUILD_SN is enabled.
src/mqtt_sn_packet.c Adds missing lower-bound validation and corrects GWINFO address-length computation for IND vs short headers.
src/mqtt_sn_client.c Routes CONNACK handling through SN_Decode_ConnectAck for proper validation.
.gitignore Ignores the new tests/test_mqtt_sn test binary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_mqtt_sn.c
Comment thread tests/test_mqtt_sn.c
@embhorn embhorn marked this pull request as ready for review June 10, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread tests/test_mqtt_sn.c Outdated

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #550

Scan targets checked: wolfmqtt-bugs, wolfmqtt-src

No new issues found in the changed files. ✅

@embhorn embhorn assigned wolfSSL-Bot and unassigned embhorn Jun 10, 2026
@embhorn embhorn requested a review from dgarske June 10, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@dgarske dgarske merged commit 6389690 into wolfSSL:master Jun 10, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants