Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for 0 packet ID for subacks #159

Merged
merged 3 commits into from
Jul 8, 2021

Conversation

muneebahmed10
Copy link
Contributor

Description:

core_mqtt_serializer.c checks for invalid packet IDs for all packets except for SUBACKs. Since packets are received from the network, we should check to make sure they are not malformed.
This adds a zero packet ID check for subacks, adds an appropriate unit test, and updates the change log.

The license file had execute permissions for some reason. This removes them.

@@ -1164,8 +1164,15 @@ static MQTTStatus_t deserializeSuback( const MQTTPacketInfo_t * pSuback,
LogDebug( ( "Packet identifier %hu.",
( unsigned short ) *pPacketIdentifier ) );

status = readSubackStatus( remainingLength - sizeof( uint16_t ),
pVariableHeader + sizeof( uint16_t ) );
if( *pPacketIdentifier == 0U )
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the MQTT_PACKET_ID_INVALID macro be moved the serializer API?https://github.com/FreeRTOS/coreMQTT/blob/main/source/include/core_mqtt.h#L55-L61

Suggested change
if( *pPacketIdentifier == 0U )
if( *pPacketIdentifier == MQTT_PACKET_ID_INVALID )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wow, I forgot about this. Possibly, but doing that is a larger change than what this PR was focused on.

@muneebahmed10 muneebahmed10 merged commit d39236e into FreeRTOS:main Jul 8, 2021
@muneebahmed10 muneebahmed10 deleted the malformed-suback branch July 8, 2021 03:11
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.

3 participants