Fix: Correct state transition check in MqttClient_Auth#439
Merged
embhorn merged 1 commit intowolfSSL:masterfrom Nov 7, 2025
Merged
Fix: Correct state transition check in MqttClient_Auth#439embhorn merged 1 commit intowolfSSL:masterfrom
embhorn merged 1 commit intowolfSSL:masterfrom
Conversation
|
Can one of the admins verify this patch? |
Member
|
HI @kaabia Please see the note I left in your other PR: |
Contributor
Author
Hello @embhorn, I can confirm the signed contributor agreement has been sent back to support@wolfssl.com Thank you for your review. I also want to mention that the test gate is currently failing due to expired certificates that need updating in the test suite:
This indicates that the failure is related to expired test assets, not the code change itself. Thank you! |
Member
|
Hi @kaabia Please rebase and push to restart the tests with the test fixes in place. |
09cd867 to
ece0a77
Compare
Contributor
Author
embhorn
requested changes
Nov 7, 2025
Fixes an issue in MqttClient_Auth where the logic failed to check for the correct message state before packet transmission. The 'Auth' write state transitions from MQTT_MSG_BEGIN to MQTT_MSG_HEADER after initial encoding. However, the subsequent conditional check was erroneously looking for MQTT_MSG_BEGIN. This logic error could cause the AUTH packet to stall if the function was called repeatedly, especially in a multithreaded context. This change updates the check to correctly look for the MQTT_MSG_HEADER state, ensuring the AUTH packet is reliably sent over the network. Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
ece0a77 to
2e87475
Compare
embhorn
approved these changes
Nov 7, 2025
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.
Fixes #442
Corrects a critical logic error in
MqttClient_Authwhere the function failed to check for the correct internal message state before attempting to send the AUTH packet payload over the network.Problem
In
MqttClient_Auth, the function transitions the write state fromMQTT_MSG_BEGINtoMQTT_MSG_HEADERafter encoding the fixed andvariable headers.
The subsequent block responsible for transmitting the packet incorrectly checked
if the state was still
MQTT_MSG_BEGIN.If the function was called again after the initial encoding, this logic error
would cause the AUTH packet to stall indefinitely because the state check
failed, preventing the
wolfMqtt_Writecall.✅ Solution
The conditional check has been updated to look for the correct state,
MQTT_MSG_HEADER, which is the state required to start the networktransmission phase.
Code Change Detail:
This ensures the AUTH packet is correctly picked up and sent upon subsequent
calls, resolving the potential stall in the authentication flow.