From 6e4bd9273bed1d2c2597740e426d9c6db33d8aa5 Mon Sep 17 00:00:00 2001 From: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Tue, 27 Jan 2026 22:28:24 +0000 Subject: [PATCH 1/2] Update APIs to size_t/uint32_t --- source/core_mqtt.c | 58 +++-- source/core_mqtt_prop_deserializer.c | 96 ++++---- source/core_mqtt_prop_serializer.c | 6 +- source/core_mqtt_serializer.c | 215 +++++++++++------- source/core_mqtt_serializer_private.c | 18 +- source/include/core_mqtt.h | 4 +- source/include/core_mqtt_serializer.h | 140 ++++++------ .../private/core_mqtt_serializer_private.h | 33 +-- .../DecodePubAckProperties_harness.c | 2 +- .../DeserializeHelpers_harness.c | 4 +- .../DeserializePublishProperties_harness.c | 3 +- .../MQTTPropGet_AssignedClientId_harness.c | 6 +- .../MQTTPropGet_AuthData_harness.c | 6 +- .../MQTTPropGet_AuthMethod_harness.c | 6 +- .../MQTTPropGet_ContentType_harness.c | 6 +- .../MQTTPropGet_CorrelationData_harness.c | 6 +- .../MQTTPropGet_MaxPacketSize_harness.c | 2 +- .../MQTTPropGet_MaxQos_harness.c | 2 +- ...QTTPropGet_MessageExpiryInterval_harness.c | 2 +- ...TTPropGet_PayloadFormatIndicator_harness.c | 2 +- .../MQTTPropGet_ReasonString_harness.c | 2 +- .../MQTTPropGet_ReceiveMax_harness.c | 2 +- .../MQTTPropGet_ResponseInfo_harness.c | 4 +- .../MQTTPropGet_ResponseTopic_harness.c | 4 +- .../MQTTPropGet_RetainAvailable_harness.c | 2 +- .../MQTTPropGet_ServerKeepAlive_harness.c | 2 +- .../MQTTPropGet_ServerRef_harness.c | 2 +- .../MQTTPropGet_SessionExpiry_harness.c | 2 +- .../MQTTPropGet_SharedSubAvailable_harness.c | 2 +- .../MQTTPropGet_SubsIdAvailable_harness.c | 2 +- .../MQTTPropGet_SubscriptionId_harness.c | 2 +- .../MQTTPropGet_TopicAlias_harness.c | 2 +- .../MQTTPropGet_TopicAliasMax_harness.c | 2 +- .../MQTTPropGet_UserProp_harness.c | 2 +- .../MQTTPropGet_WildcardId_harness.c | 2 +- .../MQTT_Connect/MQTT_Connect_harness.c | 2 +- .../MQTT_DeserializeAck_harness.c | 4 +- .../MQTT_DeserializePublish_harness.c | 4 +- .../MQTT_GetNextPropertyType_harness.c | 2 +- .../MQTT_ProcessLoop_harness.c | 6 +- .../MQTT_ReceiveLoop_harness.c | 6 +- .../MQTT_SerializeDisconnect_harness.c | 4 +- .../MQTT_SerializePublish_harness.c | 4 +- .../MQTT_SerializePublishHeader_harness.c | 4 +- .../MQTT_SerializeSubscribe_harness.c | 4 +- .../MQTT_SerializeUnsubscribe_harness.c | 4 +- .../MQTT_SkipNextProperty_harness.c | 2 +- ...deserializeSubUnsubAckProperties_harness.c | 2 +- test/unit-test/core_mqtt_serializer_utest.c | 202 ++++++++-------- test/unit-test/core_mqtt_utest.c | 112 ++++----- 50 files changed, 543 insertions(+), 470 deletions(-) diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 1942d85a1..7f15fbec8 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -135,7 +135,7 @@ static int32_t sendBuffer( MQTTContext_t * pContext, static MQTTStatus_t sendConnectWithoutCopy( MQTTContext_t * pContext, const MQTTConnectInfo_t * pConnectInfo, const MQTTPublishInfo_t * pWillInfo, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder, const MQTTPropBuilder_t * pWillPropertyBuilder ); @@ -212,7 +212,7 @@ static MQTTStatus_t sendSubscribeWithoutCopy( MQTTContext_t * pContext, const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ); /** @@ -239,7 +239,7 @@ static MQTTStatus_t sendUnsubscribeWithoutCopy( MQTTContext_t * pContext, const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ); /** @@ -298,7 +298,7 @@ static int32_t recvExact( MQTTContext_t * pContext, * @return #MQTTRecvFailed or #MQTTNoDataAvailable. */ static MQTTStatus_t discardPacket( MQTTContext_t * pContext, - size_t remainingLength, + uint32_t remainingLength, uint32_t timeoutMs ); /** @@ -702,7 +702,7 @@ static MQTTStatus_t validatePublishAckReasonCode( MQTTSuccessFailReasonCode_t re static MQTTStatus_t sendDisconnectWithoutCopy( MQTTContext_t * pContext, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ); /** @@ -1238,7 +1238,7 @@ static int32_t recvExact( MQTTContext_t * pContext, /*-----------------------------------------------------------*/ static MQTTStatus_t discardPacket( MQTTContext_t * pContext, - size_t remainingLength, + uint32_t remainingLength, uint32_t timeoutMs ) { MQTTStatus_t status = MQTTRecvFailed; @@ -1312,7 +1312,7 @@ static MQTTStatus_t discardStoredPacket( MQTTContext_t * pContext, uint32_t totalBytesReceived = 0U; bool receiveError = false; size_t mqttPacketSize = 0; - size_t remainingLength; + uint32_t remainingLength; assert( pContext != NULL ); assert( pPacketInfo != NULL ); @@ -1734,8 +1734,8 @@ static MQTTStatus_t sendPublishAcksWithProperty( MQTTContext_t * pContext, * Reason Code + 1 = 8 */ uint8_t pubAckHeader[ 8U ]; - size_t remainingLength = 0U; - size_t packetSize = 0U; + uint32_t remainingLength = 0U; + uint32_t packetSize = 0U; /* The maximum vectors required to encode and send a publish ack. * Ack Header 0 + 1 = 1 @@ -1846,7 +1846,7 @@ static MQTTStatus_t sendPublishAcksWithProperty( MQTTContext_t * pContext, if( bytesSentOrError != ( int32_t ) totalMessageLength ) { LogError( ( "Failed to send ACK packet: PacketType=%02x, " - "PacketSize=%lu.", + "PacketSize=%" PRIu32, ( unsigned int ) packetTypeByte, packetSize ) ); status = MQTTSendFailed; @@ -2642,7 +2642,7 @@ static MQTTStatus_t sendSubscribeWithoutCopy( MQTTContext_t * pContext, const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ) { MQTTStatus_t status = MQTTSuccess; @@ -2783,7 +2783,7 @@ static MQTTStatus_t sendUnsubscribeWithoutCopy( MQTTContext_t * pContext, const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ) { MQTTStatus_t status = MQTTSuccess; @@ -3057,7 +3057,7 @@ static MQTTStatus_t sendPublishWithoutCopy( MQTTContext_t * pContext, static MQTTStatus_t sendConnectWithoutCopy( MQTTContext_t * pContext, const MQTTConnectInfo_t * pConnectInfo, const MQTTPublishInfo_t * pWillInfo, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder, const MQTTPropBuilder_t * pWillPropertyBuilder ) { @@ -3810,7 +3810,7 @@ static MQTTStatus_t handleSubUnsubAck( MQTTContext_t * pContext, static MQTTStatus_t sendDisconnectWithoutCopy( MQTTContext_t * pContext, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTPropBuilder_t * pPropertyBuilder ) { int32_t bytesSentOrError; @@ -4335,7 +4335,8 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext, const MQTTPropBuilder_t * pPropertyBuilder ) { MQTTConnectionStatus_t connectStatus; - size_t remainingLength = 0UL, packetSize = 0UL; + uint32_t remainingLength = 0UL; + uint32_t packetSize = 0UL; MQTTStatus_t status = MQTTSuccess; status = validateSubscribeUnsubscribeParams( pContext, @@ -4401,8 +4402,8 @@ MQTTStatus_t MQTT_Publish( MQTTContext_t * pContext, const MQTTPropBuilder_t * pPropertyBuilder ) { size_t headerSize = 0UL; - size_t remainingLength = 0UL; - size_t packetSize = 0UL; + uint32_t remainingLength = 0UL; + uint32_t packetSize = 0UL; MQTTPublishState_t publishStatus = MQTTStateNull; MQTTConnectionStatus_t connectStatus; uint16_t topicAlias = 0U; @@ -4542,7 +4543,7 @@ MQTTStatus_t MQTT_Ping( MQTTContext_t * pContext ) { int32_t sendResult = 0; MQTTStatus_t status = MQTTSuccess; - size_t packetSize = 0U; + uint32_t packetSize = 0U; /* MQTT ping packets are of fixed length. */ uint8_t pingreqPacket[ 2U ]; MQTTFixedBuffer_t localBuffer; @@ -4634,7 +4635,8 @@ MQTTStatus_t MQTT_Unsubscribe( MQTTContext_t * pContext, const MQTTPropBuilder_t * pPropertyBuilder ) { MQTTConnectionStatus_t connectStatus; - size_t remainingLength = 0UL, packetSize = 0UL; + uint32_t remainingLength = 0UL; + uint32_t packetSize = 0UL; MQTTStatus_t status = MQTTSuccess; /* Validate arguments. */ @@ -4697,8 +4699,8 @@ MQTTStatus_t MQTT_Disconnect( MQTTContext_t * pContext, const MQTTPropBuilder_t * pPropertyBuilder, MQTTSuccessFailReasonCode_t * pReasonCode ) { - size_t packetSize = 0U; - size_t remainingLength = 0U; + uint32_t packetSize = 0U; + uint32_t remainingLength = 0U; MQTTStatus_t status = MQTTSuccess; MQTTConnectionStatus_t connectStatus; @@ -4850,9 +4852,9 @@ uint16_t MQTT_GetPacketId( MQTTContext_t * pContext ) /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_MatchTopic( const char * pTopicName, - const uint16_t topicNameLength, + const size_t topicNameLength, const char * pTopicFilter, - const uint16_t topicFilterLength, + const size_t topicFilterLength, bool * pIsMatch ) { MQTTStatus_t status = MQTTSuccess; @@ -4881,6 +4883,16 @@ MQTTStatus_t MQTT_MatchTopic( const char * pTopicName, LogError( ( "Invalid paramater: Output parameter, pIsMatch, is NULL" ) ); status = MQTTBadParameter; } + else if( CHECK_SIZE_T_OVERFLOWS_16BIT( topicNameLength ) ) + { + LogError( ( "topicNameLength must be fit in a 16-bit value (<65535)" ) ); + status = MQTTBadParameter; + } + else if( CHECK_SIZE_T_OVERFLOWS_16BIT( topicFilterLength ) ) + { + LogError( ( "topicFilterLength must be fit in a 16-bit value (<65535)" ) ); + status = MQTTBadParameter; + } else { /* Check for an exact match if the incoming topic name and the registered diff --git a/source/core_mqtt_prop_deserializer.c b/source/core_mqtt_prop_deserializer.c index 919b23bcf..6ed693091 100644 --- a/source/core_mqtt_prop_deserializer.c +++ b/source/core_mqtt_prop_deserializer.c @@ -47,7 +47,7 @@ * @return MQTTSuccess if all the checks pass; */ static inline MQTTStatus_t checkPropBuilderParams( MQTTPropBuilder_t * mqttPropBuilder, - uint32_t * currentIndex ); + size_t * currentIndex ); /** * @brief Get a uint8 property value from the property builder. @@ -65,7 +65,7 @@ static inline MQTTStatus_t checkPropBuilderParams( MQTTPropBuilder_t * mqttPropB * #MQTTBadParameter if parameters are invalid or property ID doesn't match. */ static MQTTStatus_t getPropUint8( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint8_t * property ); @@ -85,7 +85,7 @@ static MQTTStatus_t getPropUint8( MQTTPropBuilder_t * pPropertyBuilder, * #MQTTBadParameter if parameters are invalid or property ID doesn't match. */ static MQTTStatus_t getPropUint16( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint16_t * property ); @@ -105,7 +105,7 @@ static MQTTStatus_t getPropUint16( MQTTPropBuilder_t * pPropertyBuilder, * #MQTTBadParameter if parameters are invalid or property ID doesn't match. */ static MQTTStatus_t getPropUint32( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint32_t * property ); @@ -126,15 +126,15 @@ static MQTTStatus_t getPropUint32( MQTTPropBuilder_t * pPropertyBuilder, * #MQTTBadParameter if parameters are invalid or property ID doesn't match. */ static MQTTStatus_t getPropUtf8( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, const char ** property, - uint16_t * propertyLength ); + size_t * propertyLength ); /*-----------------------------------------------------------*/ static inline MQTTStatus_t checkPropBuilderParams( MQTTPropBuilder_t * mqttPropBuilder, - uint32_t * currentIndex ) + size_t * currentIndex ) { MQTTStatus_t status = MQTTSuccess; @@ -160,7 +160,7 @@ static inline MQTTStatus_t checkPropBuilderParams( MQTTPropBuilder_t * mqttPropB /*-----------------------------------------------------------*/ static MQTTStatus_t getPropUint8( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint8_t * property ) { @@ -210,7 +210,7 @@ static MQTTStatus_t getPropUint8( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ static MQTTStatus_t getPropUint16( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint16_t * property ) { @@ -263,7 +263,7 @@ static MQTTStatus_t getPropUint16( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ static MQTTStatus_t getPropUint32( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, uint32_t * property ) { @@ -316,10 +316,10 @@ static MQTTStatus_t getPropUint32( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ static MQTTStatus_t getPropUtf8( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t propertyId, const char ** property, - uint16_t * propertyLength ) + size_t * propertyLength ) { MQTTStatus_t status = checkPropBuilderParams( pPropertyBuilder, currentIndex ); @@ -368,7 +368,7 @@ static MQTTStatus_t getPropUtf8( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_GetNextPropertyType( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * property ) { MQTTStatus_t status = checkPropBuilderParams( pPropertyBuilder, currentIndex ); @@ -430,7 +430,7 @@ MQTTStatus_t MQTT_GetNextPropertyType( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_SkipNextProperty( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex ) + size_t * currentIndex ) { MQTTStatus_t status = checkPropBuilderParams( pPropertyBuilder, currentIndex ); uint8_t property; @@ -441,7 +441,7 @@ MQTTStatus_t MQTT_SkipNextProperty( MQTTPropBuilder_t * pPropertyBuilder, uint16_t dummyUint16; uint8_t dummyUint8; const char * dummyString; - uint16_t dummyStringLen; + size_t dummyStringLen; if( status != MQTTSuccess ) { @@ -541,7 +541,7 @@ MQTTStatus_t MQTT_SkipNextProperty( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_UserProp( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, MQTTUserProperty_t * pUserProperty ) { MQTTStatus_t status = checkPropBuilderParams( pPropertyBuilder, currentIndex ); @@ -594,7 +594,7 @@ MQTTStatus_t MQTTPropGet_UserProp( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_SessionExpiry( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pSessionExpiry ) { return getPropUint32( pPropertyBuilder, currentIndex, MQTT_SESSION_EXPIRY_ID, pSessionExpiry ); @@ -603,7 +603,7 @@ MQTTStatus_t MQTTPropGet_SessionExpiry( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ReceiveMax( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pReceiveMax ) { return getPropUint16( pPropertyBuilder, currentIndex, MQTT_RECEIVE_MAX_ID, pReceiveMax ); @@ -612,7 +612,7 @@ MQTTStatus_t MQTTPropGet_ReceiveMax( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_MaxQos( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pMaxQos ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_MAX_QOS_ID, pMaxQos ); @@ -621,7 +621,7 @@ MQTTStatus_t MQTTPropGet_MaxQos( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_RetainAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pRetainAvailable ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_RETAIN_AVAILABLE_ID, pRetainAvailable ); @@ -630,7 +630,7 @@ MQTTStatus_t MQTTPropGet_RetainAvailable( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_MaxPacketSize( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pMaxPacketSize ) { return getPropUint32( pPropertyBuilder, currentIndex, MQTT_MAX_PACKET_SIZE_ID, pMaxPacketSize ); @@ -639,9 +639,9 @@ MQTTStatus_t MQTTPropGet_MaxPacketSize( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_AssignedClientId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pClientId, - uint16_t * pClientIdLength ) + size_t * pClientIdLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_ASSIGNED_CLIENT_ID, pClientId, pClientIdLength ); } @@ -649,7 +649,7 @@ MQTTStatus_t MQTTPropGet_AssignedClientId( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_TopicAliasMax( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pTopicAliasMax ) { return getPropUint16( pPropertyBuilder, currentIndex, MQTT_TOPIC_ALIAS_MAX_ID, pTopicAliasMax ); @@ -658,9 +658,9 @@ MQTTStatus_t MQTTPropGet_TopicAliasMax( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ReasonString( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pReasonString, - uint16_t * pReasonStringLength ) + size_t * pReasonStringLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_REASON_STRING_ID, pReasonString, pReasonStringLength ); } @@ -668,7 +668,7 @@ MQTTStatus_t MQTTPropGet_ReasonString( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_WildcardId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pWildcardAvailable ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_WILDCARD_ID, pWildcardAvailable ); @@ -677,7 +677,7 @@ MQTTStatus_t MQTTPropGet_WildcardId( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_SubsIdAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pSubsIdAvailable ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_SUB_AVAILABLE_ID, pSubsIdAvailable ); @@ -686,7 +686,7 @@ MQTTStatus_t MQTTPropGet_SubsIdAvailable( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_SharedSubAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pSharedSubAvailable ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_SHARED_SUB_ID, pSharedSubAvailable ); @@ -695,7 +695,7 @@ MQTTStatus_t MQTTPropGet_SharedSubAvailable( MQTTPropBuilder_t * pPropertyBuilde /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ServerKeepAlive( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pServerKeepAlive ) { return getPropUint16( pPropertyBuilder, currentIndex, MQTT_SERVER_KEEP_ALIVE_ID, pServerKeepAlive ); @@ -704,9 +704,9 @@ MQTTStatus_t MQTTPropGet_ServerKeepAlive( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ResponseInfo( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pResponseInfo, - uint16_t * pResponseInfoLength ) + size_t * pResponseInfoLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_RESPONSE_INFO_ID, pResponseInfo, pResponseInfoLength ); } @@ -714,9 +714,9 @@ MQTTStatus_t MQTTPropGet_ResponseInfo( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ServerRef( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pServerRef, - uint16_t * pServerRefLength ) + size_t * pServerRefLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_SERVER_REF_ID, pServerRef, pServerRefLength ); } @@ -724,9 +724,9 @@ MQTTStatus_t MQTTPropGet_ServerRef( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_AuthMethod( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pAuthMethod, - uint16_t * pAuthMethodLen ) + size_t * pAuthMethodLen ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_AUTH_METHOD_ID, pAuthMethod, pAuthMethodLen ); } @@ -734,9 +734,9 @@ MQTTStatus_t MQTTPropGet_AuthMethod( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_AuthData( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pAuthData, - uint16_t * pAuthDataLen ) + size_t * pAuthDataLen ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_AUTH_DATA_ID, pAuthData, pAuthDataLen ); } @@ -744,7 +744,7 @@ MQTTStatus_t MQTTPropGet_AuthData( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_PayloadFormatIndicator( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pPayloadFormat ) { return getPropUint8( pPropertyBuilder, currentIndex, MQTT_PAYLOAD_FORMAT_ID, pPayloadFormat ); @@ -753,7 +753,7 @@ MQTTStatus_t MQTTPropGet_PayloadFormatIndicator( MQTTPropBuilder_t * pPropertyBu /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_MessageExpiryInterval( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pMessageExpiry ) { return getPropUint32( pPropertyBuilder, currentIndex, MQTT_MSG_EXPIRY_ID, pMessageExpiry ); @@ -762,7 +762,7 @@ MQTTStatus_t MQTTPropGet_MessageExpiryInterval( MQTTPropBuilder_t * pPropertyBui /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_TopicAlias( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pTopicAlias ) { return getPropUint16( pPropertyBuilder, currentIndex, MQTT_TOPIC_ALIAS_ID, pTopicAlias ); @@ -771,9 +771,9 @@ MQTTStatus_t MQTTPropGet_TopicAlias( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ResponseTopic( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pResponseTopic, - uint16_t * pResponseTopicLength ) + size_t * pResponseTopicLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_RESPONSE_TOPIC_ID, pResponseTopic, pResponseTopicLength ); } @@ -781,9 +781,9 @@ MQTTStatus_t MQTTPropGet_ResponseTopic( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_CorrelationData( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pCorrelationData, - uint16_t * pCorrelationDataLength ) + size_t * pCorrelationDataLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_CORRELATION_DATA_ID, pCorrelationData, pCorrelationDataLength ); } @@ -791,7 +791,7 @@ MQTTStatus_t MQTTPropGet_CorrelationData( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_SubscriptionId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pSubscriptionId ) { MQTTStatus_t status = checkPropBuilderParams( pPropertyBuilder, currentIndex ); @@ -838,9 +838,9 @@ MQTTStatus_t MQTTPropGet_SubscriptionId( MQTTPropBuilder_t * pPropertyBuilder, /*-----------------------------------------------------------*/ MQTTStatus_t MQTTPropGet_ContentType( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pContentType, - uint16_t * pContentTypeLength ) + size_t * pContentTypeLength ) { return getPropUtf8( pPropertyBuilder, currentIndex, MQTT_CONTENT_TYPE_ID, pContentType, pContentTypeLength ); } diff --git a/source/core_mqtt_prop_serializer.c b/source/core_mqtt_prop_serializer.c index e4c99ed59..662bb3eb5 100644 --- a/source/core_mqtt_prop_serializer.c +++ b/source/core_mqtt_prop_serializer.c @@ -684,11 +684,11 @@ MQTTStatus_t MQTTPropAdd_UserProp( MQTTPropBuilder_t * pPropertyBuilder, { LogError( ( "Arguments cannot be NULL: pUserProperties->userProperty->pKey=%p, " "pUserProperties->userProperty->pValue=%p, " - "Key Length = %u, Value Length = %u", + "Key Length = %d, Value Length = %d", ( void * ) userProperty->pKey, ( void * ) userProperty->pValue, - userProperty->keyLength, - userProperty->valueLength ) ); + ( int ) userProperty->keyLength, + ( int ) userProperty->valueLength ) ); status = MQTTBadParameter; } else if( ( pOptionalMqttPacketType != NULL ) && diff --git a/source/core_mqtt_serializer.c b/source/core_mqtt_serializer.c index cf8e1a365..ae52873d6 100644 --- a/source/core_mqtt_serializer.c +++ b/source/core_mqtt_serializer.c @@ -116,7 +116,7 @@ */ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, - size_t remainingLength, + uint32_t remainingLength, uint16_t packetIdentifier, const MQTTFixedBuffer_t * pFixedBuffer, bool serializePayload ); @@ -136,8 +136,8 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo, * MQTT spec; MQTTSuccess otherwise. */ static MQTTStatus_t calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, size_t publishPropertyLength ); @@ -162,8 +162,8 @@ static MQTTStatus_t calculatePublishPacketSize( const MQTTPublishInfo_t * pPubli static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, size_t subscribePropLen, uint32_t maxPacketSize, MQTTSubscriptionType_t subscriptionType ); @@ -185,7 +185,7 @@ static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t * static MQTTStatus_t validateSubscriptionSerializeParams( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ); /** @@ -220,7 +220,7 @@ static void logConnackResponse( uint8_t responseCode ); * * @return The size of the remaining length if it were to be encoded. */ -static size_t remainingLengthEncodedSize( size_t length ); +static size_t remainingLengthEncodedSize( uint32_t length ); /** * @brief Retrieves and decodes the Remaining Length from the network interface @@ -274,9 +274,9 @@ static bool incomingPacketValid( uint8_t packetType ); * * @return #MQTTSuccess or #MQTTBadResponse. */ -static MQTTStatus_t checkPublishRemainingLength( size_t remainingLength, +static MQTTStatus_t checkPublishRemainingLength( uint32_t remainingLength, MQTTQoS_t qos, - size_t qos0Minimum ); + uint32_t qos0Minimum ); /** * @brief Process the flags of an incoming PUBLISH packet. @@ -418,7 +418,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p static MQTTStatus_t deserializeSubUnsubAckProperties( MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, size_t * pSubackPropertyLength, - size_t remainingLength ); + uint32_t remainingLength ); /** * @brief Deserialize an PUBACK, PUBREC, PUBREL, or PUBCOMP packet. @@ -452,7 +452,7 @@ static MQTTStatus_t deserializePubAcks( const MQTTPacketInfo_t * pAck, **/ static MQTTStatus_t decodePubAckProperties( MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, - size_t remainingLength ); + uint32_t remainingLength ); /** * @brief Prints the appropriate message for the PUBREL, PUBACK response code if logs @@ -486,7 +486,7 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, uint16_t topicAliasMax, - size_t remainingLength ); + uint32_t remainingLength ); /** * @brief Prints and validates the appropriate message for the Disconnect response code if logs @@ -651,7 +651,7 @@ static MQTTStatus_t validateReasonCodeForAck( uint8_t ackPacketType, /*-----------------------------------------------------------*/ -static size_t remainingLengthEncodedSize( size_t length ) +static size_t remainingLengthEncodedSize( uint32_t length ) { size_t encodedSize; @@ -689,18 +689,19 @@ static size_t remainingLengthEncodedSize( size_t length ) /*-----------------------------------------------------------*/ static MQTTStatus_t calculatePublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, size_t publishPropertyLength ) { MQTTStatus_t status = MQTTSuccess; - size_t packetSize = 0, propertyAndPayloadLimit = 0; - + uint32_t packetSize = 0; + uint32_t propertyAndPayloadLimit = 0; assert( pPublishInfo != NULL ); assert( pRemainingLength != NULL ); assert( pPacketSize != NULL ); + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ); /* The variable header of a PUBLISH packet always contains the topic name. * The first 2 bytes of UTF-8 string contains length of the string. @@ -848,7 +849,7 @@ static MQTTStatus_t deserializePubAcks( const MQTTPacketInfo_t * pAck, /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_SerializePublishHeaderWithoutTopic( const MQTTPublishInfo_t * pPublishInfo, - size_t remainingLength, + uint32_t remainingLength, uint8_t * pBuffer, size_t * headerSize ) { @@ -940,7 +941,7 @@ MQTTStatus_t MQTT_SerializePublishHeaderWithoutTopic( const MQTTPublishInfo_t * static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, - size_t remainingLength, + uint32_t remainingLength, uint16_t packetIdentifier, const MQTTFixedBuffer_t * pFixedBuffer, bool serializePayload ) @@ -1099,7 +1100,7 @@ static MQTTStatus_t processRemainingLength( const uint8_t * pBuffer, const size_t * pIndex, MQTTPacketInfo_t * pIncomingPacket ) { - size_t remainingLength = 0; + uint32_t remainingLength = 0; size_t multiplier = 1; size_t bytesDecoded = 0; size_t expectedSize = 0; @@ -1209,9 +1210,9 @@ static bool incomingPacketValid( uint8_t packetType ) /*-----------------------------------------------------------*/ -static MQTTStatus_t checkPublishRemainingLength( size_t remainingLength, +static MQTTStatus_t checkPublishRemainingLength( uint32_t remainingLength, MQTTQoS_t qos, - size_t qos0Minimum ) + uint32_t qos0Minimum ) { MQTTStatus_t status = MQTTSuccess; @@ -1583,8 +1584,8 @@ static MQTTStatus_t deserializeConnack( MQTTConnectionProperties_t * pConnackPro static MQTTStatus_t calculateSubscriptionPacketSize( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, size_t subscribePropLen, uint32_t maxPacketSize, MQTTSubscriptionType_t subscriptionType ) @@ -1746,7 +1747,7 @@ static MQTTStatus_t deserializeSubUnsubAck( const MQTTPacketInfo_t * incomingPac { MQTTStatus_t status = MQTTSuccess; uint8_t * pIndex = NULL; - size_t remainingLength = 0U; + uint32_t remainingLength = 0U; size_t statusTotalBytes = 0U; const uint8_t * pStatusStart; size_t propertyLength = 0U; @@ -1807,7 +1808,7 @@ static MQTTStatus_t deserializeSubUnsubAck( const MQTTPacketInfo_t * incomingPac static MQTTStatus_t validateSubscriptionSerializeParams( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t status = MQTTSuccess; @@ -2054,7 +2055,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p { uint8_t propertyId = *pVariableHeader; const char * data; - uint16_t dataLength; + size_t dataLength; pVariableHeader = &pVariableHeader[ 1 ]; propertyLength -= sizeof( uint8_t ); @@ -2218,7 +2219,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p { /* Proper uses for the reason string in the Client would include using this information * in an exception thrown by the Client code, or writing this string to a log. */ - LogInfo( ( "Reason string from server: %.*s", dataLength, data ) ); + LogInfo( ( "Reason string from server: %.*s", ( int ) dataLength, data ) ); if( pPropBuffer != NULL ) { @@ -2231,7 +2232,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, &valueLength, &propertyLength, &pVariableHeader ); if( status == MQTTSuccess ) @@ -2353,7 +2354,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p } else { - LogDebug( ( "Response information: %.*s", dataLength, data ) ); + LogDebug( ( "Response information: %.*s", ( int ) dataLength, data ) ); if( pPropBuffer != NULL ) { @@ -2369,7 +2370,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p if( status == MQTTSuccess ) { - LogDebug( ( "Server reference: %.*s", dataLength, data ) ); + LogDebug( ( "Server reference: %.*s", ( int ) dataLength, data ) ); if( pPropBuffer != NULL ) { @@ -2384,7 +2385,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p if( status == MQTTSuccess ) { - LogDebug( ( "Authentication method received: %.*s", dataLength, data ) ); + LogDebug( ( "Authentication method received: %.*s", ( int ) dataLength, data ) ); if( pPropBuffer != NULL ) { @@ -2401,7 +2402,7 @@ static MQTTStatus_t deserializeConnackProperties( MQTTConnectionProperties_t * p if( status == MQTTSuccess ) { - LogDebug( ( "Auth data received: %.*s", dataLength, data ) ); + LogDebug( ( "Auth data received: %.*s", ( int ) dataLength, data ) ); if( pPropBuffer != NULL ) { @@ -2494,13 +2495,13 @@ static MQTTStatus_t logAckResponse( MQTTSuccessFailReasonCode_t reasonCode, static MQTTStatus_t deserializeSubUnsubAckProperties( MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, size_t * pSubackPropertyLength, - size_t remainingLength ) + uint32_t remainingLength ) { MQTTStatus_t status = MQTTSuccess; uint32_t propertyLength = 0U; uint8_t * pLocalIndex = pIndex; const char * pReasonString; - uint16_t reasonStringLength; + size_t reasonStringLength; bool reasonString = false; status = decodeVariableLength( pLocalIndex, remainingLength - 2U, &propertyLength ); @@ -2543,9 +2544,9 @@ static MQTTStatus_t deserializeSubUnsubAckProperties( MQTTPropBuilder_t * pPropB case MQTT_USER_PROPERTY_ID: { const char * propertyKey; - uint16_t propertyKeyLen; + size_t propertyKeyLen; const char * propertyValue; - uint16_t propertyValueLen; + size_t propertyValueLen; status = decodeUserProp( &propertyKey, &propertyKeyLen, &propertyValue, &propertyValueLen, &propertyLength, &pLocalIndex ); } @@ -2576,6 +2577,10 @@ static void serializeConnectPacket( const MQTTConnectInfo_t * pConnectInfo, assert( pConnectInfo != NULL ); assert( pFixedBuffer != NULL ); assert( pFixedBuffer->pBuffer != NULL ); + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->clientIdentifierLength ) ); + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->userNameLength ) ); + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->passwordLength ) ); + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pWillInfo->topicNameLength ) ); pIndex = pFixedBuffer->pBuffer; @@ -2655,13 +2660,13 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, uint16_t topicAliasMax, - size_t remainingLength ) + uint32_t remainingLength ) { MQTTStatus_t status = MQTTSuccess; uint32_t propertyLength = 0U; uint8_t * pLocalIndex = pIndex; uint32_t subscriptionId; - size_t remainingLengthForProperties; + uint32_t remainingLengthForProperties; bool contentType = false; bool messageExpiryInterval = false; bool responseTopic = false; @@ -2670,6 +2675,8 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn bool correlationData = false; uint16_t topicAliasVal; + assert( !CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ); + /* Decode Property Length. */ remainingLengthForProperties = remainingLength; remainingLengthForProperties -= pPublishInfo->topicNameLength + sizeof( uint16_t ); @@ -2741,7 +2748,7 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn case MQTT_RESPONSE_TOPIC_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &responseTopic, &pLocalIndex ); } break; @@ -2749,7 +2756,7 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn case MQTT_CORRELATION_DATA_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &correlationData, &pLocalIndex ); } break; @@ -2764,7 +2771,7 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn case MQTT_CONTENT_TYPE_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &contentType, &pLocalIndex ); } break; @@ -2783,9 +2790,9 @@ static MQTTStatus_t deserializePublishProperties( MQTTPublishInfo_t * pPublishIn case MQTT_USER_PROPERTY_ID: { const char * pPropertyKey; - uint16_t propertyKeyLen; + size_t propertyKeyLen; const char * pPropertyValue; - uint16_t propertyValueLen; + size_t propertyValueLen; status = decodeUserProp( &pPropertyKey, &propertyKeyLen, &pPropertyValue, @@ -2894,7 +2901,7 @@ MQTTStatus_t updateContextWithConnectProps( const MQTTPropBuilder_t * pPropBuild case MQTT_AUTH_METHOD_ID: { const char * data; - uint16_t dataLength; + size_t dataLength; status = decodeUtf8( &data, &dataLength, &propertyLength, &used, &pIndex ); } break; @@ -2902,7 +2909,7 @@ MQTTStatus_t updateContextWithConnectProps( const MQTTPropBuilder_t * pPropBuild case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, @@ -3050,7 +3057,7 @@ MQTTStatus_t MQTT_GetConnectPacketSize( const MQTTConnectInfo_t * pConnectInfo, static MQTTStatus_t decodePubAckProperties( MQTTPropBuilder_t * pPropBuffer, uint8_t * pIndex, - size_t remainingLength ) + uint32_t remainingLength ) { uint32_t propertyLength = 0U; MQTTStatus_t status = MQTTSuccess; @@ -3095,7 +3102,7 @@ static MQTTStatus_t decodePubAckProperties( MQTTPropBuilder_t * pPropBuffer, case MQTT_REASON_STRING_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &reasonString, &pLocalIndex ); break; } @@ -3103,9 +3110,9 @@ static MQTTStatus_t decodePubAckProperties( MQTTPropBuilder_t * pPropBuffer, case MQTT_USER_PROPERTY_ID: { const char * pPropertyKey; - uint16_t propertyKeyLen; + size_t propertyKeyLen; const char * pPropertyValue; - uint16_t propertyValueLen; + size_t propertyValueLen; status = decodeUserProp( &pPropertyKey, &propertyKeyLen, &pPropertyValue, @@ -3231,6 +3238,26 @@ MQTTStatus_t MQTT_SerializeConnect( const MQTTConnectInfo_t * pConnectInfo, LogError( ( "pWillInfo->pTopicName cannot be NULL if Will is present." ) ); status = MQTTBadParameter; } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->clientIdentifierLength ) ) + { + LogError( ( "clientIdentifierLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->userNameLength ) ) + { + LogError( ( "userNameLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pConnectInfo->passwordLength ) ) + { + LogError( ( "passwordLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pWillInfo->topicNameLength ) ) + { + LogError( ( "topicNameLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } else { /* Calculate CONNECT packet size. Overflow in in this addition is not checked @@ -3266,8 +3293,8 @@ MQTTStatus_t MQTT_SerializeConnect( const MQTTConnectInfo_t * pConnectInfo, MQTTStatus_t MQTT_GetSubscribePacketSize( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t * pSubscribeProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize ) { MQTTStatus_t status = MQTTSuccess; @@ -3309,7 +3336,7 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL size_t subscriptionCount, const MQTTPropBuilder_t * pSubscribeProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { size_t i = 0; @@ -3420,8 +3447,8 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL MQTTStatus_t MQTT_GetUnsubscribePacketSize( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t * pUnsubscribeProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize ) { MQTTStatus_t status = MQTTSuccess; @@ -3489,7 +3516,7 @@ MQTTStatus_t MQTT_ValidateUnsubscribeProperties( const MQTTPropBuilder_t * pProp case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, &valueLength, &propertyLength, &pIndex ); if( status == MQTTSuccess ) @@ -3516,7 +3543,7 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio size_t subscriptionCount, const MQTTPropBuilder_t * pUnsubscribeProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t status = MQTTSuccess; @@ -3571,8 +3598,8 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize ) { MQTTStatus_t status = MQTTSuccess; @@ -3592,6 +3619,11 @@ MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, ( void * ) pPacketSize ) ); status = MQTTBadParameter; } + else if( CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ) + { + LogError( ( "Topic name length must be smaller than 65535." ) ); + status = MQTTBadParameter; + } else { status = calculatePublishPacketSize( pPublishInfo, pRemainingLength, @@ -3606,7 +3638,7 @@ MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t status = MQTTSuccess; @@ -3656,6 +3688,11 @@ MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, LogError( ( "Duplicate flag is set for PUBLISH with Qos 0." ) ); status = MQTTBadParameter; } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ) + { + LogError( ( "topicNameLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } else { /* Length of serialized packet = First byte @@ -3693,7 +3730,7 @@ MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, MQTTStatus_t MQTT_SerializePublishHeader( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer, size_t * pHeaderSize ) { @@ -3724,6 +3761,11 @@ MQTTStatus_t MQTT_SerializePublishHeader( const MQTTPublishInfo_t * pPublishInfo ( unsigned short ) pPublishInfo->topicNameLength ) ); status = MQTTBadParameter; } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ) + { + LogError( ( "topicNameLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } else if( ( pPublishInfo->qos != MQTTQoS0 ) && ( packetId == 0U ) ) { LogError( ( "Packet Id is 0 for publish with QoS=%hu.", @@ -3873,8 +3915,8 @@ MQTTStatus_t MQTT_SerializeAck( const MQTTFixedBuffer_t * pFixedBuffer, /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnectProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, MQTTSuccessFailReasonCode_t * pReasonCode ) { @@ -3970,7 +4012,7 @@ MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnect MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProperties, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t status = MQTTSuccess; @@ -4040,7 +4082,7 @@ MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProp /*-----------------------------------------------------------*/ -MQTTStatus_t MQTT_GetPingreqPacketSize( size_t * pPacketSize ) +MQTTStatus_t MQTT_GetPingreqPacketSize( uint32_t * pPacketSize ) { MQTTStatus_t status = MQTTSuccess; @@ -4570,7 +4612,7 @@ MQTTStatus_t MQTT_ValidateWillProperties( const MQTTPropBuilder_t * pPropertyBui uint8_t propertyId = *pIndex; bool used = false; const char * data; - uint16_t dataLength; + size_t dataLength; pIndex = &pIndex[ 1 ]; propertyLength -= sizeof( uint8_t ); @@ -4681,7 +4723,7 @@ MQTTStatus_t MQTT_ValidateWillProperties( const MQTTPropBuilder_t * pPropertyBui case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, @@ -4728,7 +4770,7 @@ MQTTStatus_t MQTT_ValidateConnectProperties( const MQTTPropBuilder_t * pProperty uint8_t propertyId = *pIndex; bool used = false; const char * data; - uint16_t dataLength; + size_t dataLength; pIndex = &pIndex[ 1 ]; propertyLength -= sizeof( uint8_t ); @@ -4902,7 +4944,7 @@ MQTTStatus_t MQTT_ValidateConnectProperties( const MQTTPropBuilder_t * pProperty case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, @@ -5001,7 +5043,7 @@ MQTTStatus_t MQTT_ValidateSubscribeProperties( bool isSubscriptionIdAvailable, case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, &valueLength, &propertyLength, &pLocalIndex ); if( status == MQTTSuccess ) @@ -5077,7 +5119,7 @@ MQTTStatus_t MQTT_ValidatePublishProperties( uint16_t serverTopicAliasMax, case MQTT_RESPONSE_TOPIC_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &used, &pLocalIndex ); break; } @@ -5096,9 +5138,9 @@ MQTTStatus_t MQTT_ValidatePublishProperties( uint16_t serverTopicAliasMax, case MQTT_USER_PROPERTY_ID: { const char * pPropertyKey; - uint16_t propertyKeyLen; + size_t propertyKeyLen; const char * pPropertyValue; - uint16_t propertyValueLen; + size_t propertyValueLen; status = decodeUserProp( &pPropertyKey, &propertyKeyLen, &pPropertyValue, @@ -5161,6 +5203,11 @@ MQTTStatus_t MQTT_ValidatePublishParams( const MQTTPublishInfo_t * pPublishInfo, ( unsigned short ) pPublishInfo->topicNameLength ) ); status = MQTTBadParameter; } + else if( !CHECK_SIZE_T_OVERFLOWS_16BIT( pPublishInfo->topicNameLength ) ) + { + LogError( ( "topicNameLength must be less than 65535 to fit in 16-bits." ) ); + status = MQTTBadParameter; + } else if( maxPacketSize == 0U ) { status = MQTTBadParameter; @@ -5199,7 +5246,7 @@ MQTTStatus_t MQTT_ValidatePublishAckProperties( const MQTTPropBuilder_t * pPrope case MQTT_REASON_STRING_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &used, &pIndex ); } break; @@ -5207,7 +5254,7 @@ MQTTStatus_t MQTT_ValidatePublishAckProperties( const MQTTPropBuilder_t * pPrope case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, @@ -5228,8 +5275,8 @@ MQTTStatus_t MQTT_ValidatePublishAckProperties( const MQTTPropBuilder_t * pPrope /*-----------------------------------------------------------*/ -MQTTStatus_t MQTT_GetAckPacketSize( size_t * pRemainingLength, - size_t * pPacketSize, +MQTTStatus_t MQTT_GetAckPacketSize( uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, size_t ackPropertyLength ) { @@ -5334,7 +5381,7 @@ MQTTStatus_t MQTT_ValidateDisconnectProperties( uint32_t connectSessionExpiry, case MQTT_REASON_STRING_ID: { const char * pProperty; - uint16_t length; + size_t length; status = decodeUtf8( &pProperty, &length, &propertyLength, &used, &pIndex ); } break; @@ -5342,7 +5389,7 @@ MQTTStatus_t MQTT_ValidateDisconnectProperties( uint32_t connectSessionExpiry, case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, &valueLength, &propertyLength, &pIndex ); } break; @@ -5468,17 +5515,17 @@ static MQTTStatus_t validateIncomingDisconnectProperties( uint8_t * pIndex, MQTTStatus_t status = MQTTSuccess; uint8_t * pLocalIndex = pIndex; const char * pReasonString; - uint16_t reasonStringLength; + size_t reasonStringLength; const char * pServerRef; - uint16_t pServerRefLength; + size_t pServerRefLength; uint32_t propertyLength = disconnectPropertyLength; + bool reasonString = false; + bool serverRef = false; while( ( propertyLength > 0U ) && ( status == MQTTSuccess ) ) { /* Decode the property id. */ uint8_t propertyId = *pLocalIndex; - bool reasonString = false; - bool serverRef = false; pLocalIndex = &pLocalIndex[ 1 ]; propertyLength -= sizeof( uint8_t ); @@ -5492,7 +5539,7 @@ static MQTTStatus_t validateIncomingDisconnectProperties( uint8_t * pIndex, case MQTT_USER_PROPERTY_ID: { const char * key, * value; - uint16_t keyLength, valueLength; + size_t keyLength, valueLength; status = decodeUserProp( &key, &keyLength, &value, &valueLength, &propertyLength, &pLocalIndex ); } break; diff --git a/source/core_mqtt_serializer_private.c b/source/core_mqtt_serializer_private.c index f7ed298cf..7d6aea607 100644 --- a/source/core_mqtt_serializer_private.c +++ b/source/core_mqtt_serializer_private.c @@ -114,17 +114,17 @@ uint8_t * encodeString( uint8_t * pDestination, /*-----------------------------------------------------------*/ MQTTStatus_t decodeUserProp( const char ** pPropertyKey, - uint16_t * pPropertyKeyLen, + size_t * pPropertyKeyLen, const char ** pPropertyValue, - uint16_t * pPropertyValueLen, + size_t * pPropertyValueLen, uint32_t * pPropertyLength, uint8_t ** pIndex ) { MQTTStatus_t status = MQTTSuccess; const char * pKey = NULL; const char * pValue = NULL; - uint16_t keyLength = 0U; - uint16_t valueLength = 0U; + size_t keyLength = 0U; + size_t valueLength = 0U; bool used = false; assert( pIndex != NULL ); @@ -275,7 +275,7 @@ MQTTStatus_t decodeUint8t( uint8_t * pProperty, /*-----------------------------------------------------------*/ MQTTStatus_t decodeUtf8( const char ** pProperty, - uint16_t * pLength, + size_t * pLength, uint32_t * pPropertyLength, bool * pUsed, uint8_t ** pIndex ) @@ -434,7 +434,7 @@ uint8_t * encodeVariableLength( uint8_t * pDestination, uint8_t * serializeAckFixed( uint8_t * pIndex, uint8_t packetType, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, MQTTSuccessFailReasonCode_t reasonCode ) { uint8_t * pIndexLocal = pIndex; @@ -538,7 +538,7 @@ uint8_t * serializeConnectFixedHeader( uint8_t * pIndex, /*-----------------------------------------------------------*/ -uint8_t * serializeSubscribeHeader( size_t remainingLength, +uint8_t * serializeSubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ) { @@ -562,7 +562,7 @@ uint8_t * serializeSubscribeHeader( size_t remainingLength, /*-----------------------------------------------------------*/ -uint8_t * serializeUnsubscribeHeader( size_t remainingLength, +uint8_t * serializeUnsubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ) { @@ -588,7 +588,7 @@ uint8_t * serializeUnsubscribeHeader( size_t remainingLength, uint8_t * serializeDisconnectFixed( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength ) + uint32_t remainingLength ) { uint8_t * pIndexLocal = pIndex; diff --git a/source/include/core_mqtt.h b/source/include/core_mqtt.h index 70b107724..41fc591eb 100644 --- a/source/include/core_mqtt.h +++ b/source/include/core_mqtt.h @@ -1345,9 +1345,9 @@ uint16_t MQTT_GetPacketId( MQTTContext_t * pContext ); * @endcode */ MQTTStatus_t MQTT_MatchTopic( const char * pTopicName, - const uint16_t topicNameLength, + const size_t topicNameLength, const char * pTopicFilter, - const uint16_t topicFilterLength, + const size_t topicFilterLength, bool * pIsMatch ); /** diff --git a/source/include/core_mqtt_serializer.h b/source/include/core_mqtt_serializer.h index b14bdf09e..648a37539 100644 --- a/source/include/core_mqtt_serializer.h +++ b/source/include/core_mqtt_serializer.h @@ -310,7 +310,7 @@ typedef struct MQTTConnectInfo /** * @brief Length of the client identifier. */ - uint16_t clientIdentifierLength; + size_t clientIdentifierLength; /** * @brief MQTT user name. Set to NULL if not used. @@ -320,7 +320,7 @@ typedef struct MQTTConnectInfo /** * @brief Length of MQTT user name. Set to 0 if not used. */ - uint16_t userNameLength; + size_t userNameLength; /** * @brief MQTT password. Set to NULL if not used. @@ -330,7 +330,7 @@ typedef struct MQTTConnectInfo /** * @brief Length of MQTT password. Set to 0 if not used. */ - uint16_t passwordLength; + size_t passwordLength; } MQTTConnectInfo_t; /** @@ -362,7 +362,7 @@ typedef struct MQTTSubscribeInfo /** * @brief Length of subscription topic filter - unsigned long */ - uint16_t topicFilterLength; + size_t topicFilterLength; /** * @brief no local option for subscription. Include protocol error if noLocalOption = 1 in a shared subscription */ @@ -416,7 +416,7 @@ typedef struct MQTTPublishInfo /** * @brief Length of topic name. */ - uint16_t topicNameLength; + size_t topicNameLength; /** * @brief Message payload. @@ -431,7 +431,7 @@ typedef struct MQTTPublishInfo /** * @brief Length of the properties. */ - uint32_t propertyLength; + size_t propertyLength; } MQTTPublishInfo_t; @@ -469,8 +469,8 @@ typedef struct MQTTPacketInfo typedef struct MQTTPropBuilder { uint8_t * pBuffer; /**< @brief Pointer to the buffer for storing properties. */ - uint32_t bufferLength; /**< @brief Total length of the buffer available for properties. */ - uint32_t currentIndex; /**< @brief Current position in the buffer where next property will be written. */ + size_t bufferLength; /**< @brief Total length of the buffer available for properties. */ + size_t currentIndex; /**< @brief Current position in the buffer where next property will be written. */ uint32_t fieldSet; /**< @brief Bitfield tracking which properties have been added. */ } MQTTPropBuilder_t; @@ -707,7 +707,7 @@ typedef struct MQTTUserProperty /** * @brief Length of the key. */ - uint16_t keyLength; + size_t keyLength; /** * @brief value. */ @@ -715,7 +715,7 @@ typedef struct MQTTUserProperty /** * @brief Length of the value. */ - uint16_t valueLength; + size_t valueLength; } MQTTUserProperty_t; /** @@ -938,8 +938,8 @@ MQTTStatus_t MQTT_SerializeConnect( const MQTTConnectInfo_t * pConnectInfo, MQTTStatus_t MQTT_GetSubscribePacketSize( const MQTTSubscribeInfo_t * pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t * pSubscribeProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize ); /* @[declare_mqtt_getsubscribepacketsize] */ @@ -1013,7 +1013,7 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL size_t subscriptionCount, const MQTTPropBuilder_t * pSubscribeProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ); /* @[declare_mqtt_serializesubscribe] */ @@ -1077,8 +1077,8 @@ MQTTStatus_t MQTT_SerializeSubscribe( const MQTTSubscribeInfo_t * pSubscriptionL MQTTStatus_t MQTT_GetUnsubscribePacketSize( const MQTTSubscribeInfo_t* pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t * pUnsubscribeProperties, - size_t* pRemainingLength, - size_t* pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize); /* @[declare_mqtt_getunsubscribepacketsize] */ @@ -1161,7 +1161,7 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio size_t subscriptionCount, const MQTTPropBuilder_t * pUnsubscribeProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ); /* @[declare_mqtt_serializeunsubscribe] */ @@ -1227,8 +1227,8 @@ MQTTStatus_t MQTT_SerializeUnsubscribe( const MQTTSubscribeInfo_t * pSubscriptio /* @[declare_mqtt_getpublishpacketsize] */ MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize); /* @[declare_mqtt_getpublishpacketsize] */ @@ -1302,7 +1302,7 @@ MQTTStatus_t MQTT_GetPublishPacketSize( const MQTTPublishInfo_t * pPublishInfo, MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ); /* @[declare_mqtt_serializepublish] */ @@ -1321,7 +1321,7 @@ MQTTStatus_t MQTT_SerializePublish( const MQTTPublishInfo_t * pPublishInfo, */ /* @[declare_mqtt_serializepublishheaderwithouttopic] */ MQTTStatus_t MQTT_SerializePublishHeaderWithoutTopic( const MQTTPublishInfo_t * pPublishInfo, - size_t remainingLength, + uint32_t remainingLength, uint8_t * pBuffer, size_t * headerSize ); /* @[declare_mqtt_serializepublishheaderwithouttopic] */ @@ -1407,7 +1407,7 @@ MQTTStatus_t MQTT_SerializePublishHeaderWithoutTopic( const MQTTPublishInfo_t * MQTTStatus_t MQTT_SerializePublishHeader( const MQTTPublishInfo_t * pPublishInfo, const MQTTPropBuilder_t * pPublishProperties, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer, size_t * pHeaderSize ); /* @[declare_mqtt_serializepublishheader] */ @@ -1505,8 +1505,8 @@ MQTTStatus_t MQTT_SerializeAck( const MQTTFixedBuffer_t * pFixedBuffer, */ /* @[declare_mqtt_getdisconnectpacketsize] */ MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnectProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, MQTTSuccessFailReasonCode_t * pReasonCode ); /* @[declare_mqtt_getdisconnectpacketsize] */ @@ -1566,7 +1566,7 @@ MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnect /* @[declare_mqtt_serializedisconnect] */ MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProperties, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ); /* @[declare_mqtt_serializedisconnect] */ @@ -1595,7 +1595,7 @@ MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProp * @endcode */ /* @[declare_mqtt_getpingreqpacketsize] */ -MQTTStatus_t MQTT_GetPingreqPacketSize( size_t * pPacketSize ); +MQTTStatus_t MQTT_GetPingreqPacketSize( uint32_t * pPacketSize ); /* @[declare_mqtt_getpingreqpacketsize] */ /** @@ -1707,8 +1707,8 @@ MQTTStatus_t MQTT_SerializePingreq( const MQTTFixedBuffer_t * pFixedBuffer ); * @endcode */ /* @[declare_mqtt_deserializepublish] */ -MQTTStatus_t MQTT_DeserializePublish( const MQTTPacketInfo_t* pIncomingPacket, - uint16_t* pPacketId, +MQTTStatus_t MQTT_DeserializePublish( const MQTTPacketInfo_t * pIncomingPacket, + uint16_t * pPacketId, MQTTPublishInfo_t * pPublishInfo, MQTTPropBuilder_t * propBuffer, uint32_t maxPacketSize, @@ -2396,7 +2396,7 @@ MQTTStatus_t MQTTPropAdd_ReasonString( MQTTPropBuilder_t* pPropertyBuilder, * - #MQTTBadParameter if an invalid parameter is passed */ /* @[declare_mqtt_validatesubscribeproperties] */ -MQTTStatus_t MQTT_ValidateSubscribeProperties( bool isSubscriptionIdAvailable, const MQTTPropBuilder_t* propBuilder ); +MQTTStatus_t MQTT_ValidateSubscribeProperties( bool isSubscriptionIdAvailable, const MQTTPropBuilder_t * propBuilder ); /* @[declare_mqtt_validatesubscribeproperties] */ /** @@ -2435,7 +2435,7 @@ MQTTStatus_t MQTT_ValidateSubscribeProperties( bool isSubscriptionIdAvailable, c * @endcode */ -MQTTStatus_t updateContextWithConnectProps( const MQTTPropBuilder_t* pPropBuilder, MQTTConnectionProperties_t* pConnectProperties ); +MQTTStatus_t updateContextWithConnectProps( const MQTTPropBuilder_t * pPropBuilder, MQTTConnectionProperties_t * pConnectProperties ); /** * @brief Get the property type at the current index in the property builder. @@ -2454,7 +2454,7 @@ MQTTStatus_t updateContextWithConnectProps( const MQTTPropBuilder_t* pPropBuilde * or the property type is not recognized. */ MQTTStatus_t MQTT_GetNextPropertyType( MQTTPropBuilder_t * mqttPropBuilder, - uint32_t * index, + size_t * index, uint8_t * property ); /** @@ -2519,7 +2519,7 @@ MQTTStatus_t MQTT_GetNextPropertyType( MQTTPropBuilder_t * mqttPropBuilder, * @endcode */ MQTTStatus_t MQTT_SkipNextProperty( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex ); + size_t * currentIndex ); /** * @brief Get User Property from property builder. @@ -2533,7 +2533,7 @@ MQTTStatus_t MQTT_SkipNextProperty( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_userprop] */ MQTTStatus_t MQTTPropGet_UserProp( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, MQTTUserProperty_t * pUserProperty ); /* @[declare_mqttpropget_userprop] */ @@ -2549,7 +2549,7 @@ MQTTStatus_t MQTTPropGet_UserProp( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_sessionexpiry] */ MQTTStatus_t MQTTPropGet_SessionExpiry( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pSessionExpiry ); /* @[declare_mqttpropget_sessionexpiry] */ @@ -2565,7 +2565,7 @@ MQTTStatus_t MQTTPropGet_SessionExpiry( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_receivemax] */ MQTTStatus_t MQTTPropGet_ReceiveMax( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pReceiveMax ); /* @[declare_mqttpropget_receivemax] */ @@ -2581,7 +2581,7 @@ MQTTStatus_t MQTTPropGet_ReceiveMax( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_maxqos] */ MQTTStatus_t MQTTPropGet_MaxQos( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pMaxQos ); /* @[declare_mqttpropget_maxqos] */ @@ -2597,7 +2597,7 @@ MQTTStatus_t MQTTPropGet_MaxQos( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_retainavailable] */ MQTTStatus_t MQTTPropGet_RetainAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pRetainAvailable ); /* @[declare_mqttpropget_retainavailable] */ @@ -2613,7 +2613,7 @@ MQTTStatus_t MQTTPropGet_RetainAvailable( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_maxpacketsize] */ MQTTStatus_t MQTTPropGet_MaxPacketSize( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pMaxPacketSize ); /* @[declare_mqttpropget_maxpacketsize] */ @@ -2630,9 +2630,9 @@ MQTTStatus_t MQTTPropGet_MaxPacketSize( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_assignedclientid] */ MQTTStatus_t MQTTPropGet_AssignedClientId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pClientId, - uint16_t * pClientIdLength ); + size_t * pClientIdLength ); /* @[declare_mqttpropget_assignedclientid] */ /** @@ -2647,7 +2647,7 @@ MQTTStatus_t MQTTPropGet_AssignedClientId( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_topicaliasmax] */ MQTTStatus_t MQTTPropGet_TopicAliasMax( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pTopicAliasMax ); /* @[declare_mqttpropget_topicaliasmax] */ @@ -2664,9 +2664,9 @@ MQTTStatus_t MQTTPropGet_TopicAliasMax( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_reasonstring] */ MQTTStatus_t MQTTPropGet_ReasonString( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pReasonString, - uint16_t * pReasonStringLength ); + size_t * pReasonStringLength ); /* @[declare_mqttpropget_reasonstring] */ /** @@ -2681,7 +2681,7 @@ MQTTStatus_t MQTTPropGet_ReasonString( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_wildcardid] */ MQTTStatus_t MQTTPropGet_WildcardId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pWildcardAvailable ); /* @[declare_mqttpropget_wildcardid] */ @@ -2697,7 +2697,7 @@ MQTTStatus_t MQTTPropGet_WildcardId( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_subsidavailable] */ MQTTStatus_t MQTTPropGet_SubsIdAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pSubsIdAvailable ); /* @[declare_mqttpropget_subsidavailable] */ @@ -2713,7 +2713,7 @@ MQTTStatus_t MQTTPropGet_SubsIdAvailable( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_sharedsubavailable] */ MQTTStatus_t MQTTPropGet_SharedSubAvailable( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint8_t * pSharedSubAvailable ); /* @[declare_mqttpropget_sharedsubavailable] */ @@ -2729,7 +2729,7 @@ MQTTStatus_t MQTTPropGet_SharedSubAvailable( MQTTPropBuilder_t * pPropertyBuilde */ /* @[declare_mqttpropget_serverkeepalive] */ MQTTStatus_t MQTTPropGet_ServerKeepAlive( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pServerKeepAlive ); /* @[declare_mqttpropget_serverkeepalive] */ @@ -2746,9 +2746,9 @@ MQTTStatus_t MQTTPropGet_ServerKeepAlive( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_responseinfo] */ MQTTStatus_t MQTTPropGet_ResponseInfo( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pResponseInfo, - uint16_t * pResponseInfoLength ); + size_t * pResponseInfoLength ); /* @[declare_mqttpropget_responseinfo] */ /** @@ -2764,9 +2764,9 @@ MQTTStatus_t MQTTPropGet_ResponseInfo( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_serverref] */ MQTTStatus_t MQTTPropGet_ServerRef( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pServerRef, - uint16_t * pServerRefLength ); + size_t * pServerRefLength ); /* @[declare_mqttpropget_serverref] */ /** @@ -2782,9 +2782,9 @@ MQTTStatus_t MQTTPropGet_ServerRef( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_authmethod] */ MQTTStatus_t MQTTPropGet_AuthMethod( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pAuthMethod, - uint16_t * pAuthMethodLen ); + size_t * pAuthMethodLen ); /* @[declare_mqttpropget_authmethod] */ /** @@ -2800,9 +2800,9 @@ MQTTStatus_t MQTTPropGet_AuthMethod( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_authdata] */ MQTTStatus_t MQTTPropGet_AuthData( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pAuthData, - uint16_t * pAuthDataLen ); + size_t * pAuthDataLen ); /* @[declare_mqttpropget_authdata] */ /** @@ -2817,8 +2817,8 @@ MQTTStatus_t MQTTPropGet_AuthData( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_payloadformatindicator] */ MQTTStatus_t MQTTPropGet_PayloadFormatIndicator( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, - uint8_t * pPayloadFormat ); + size_t * currentIndex, + uint8_t * pPayloadFormat ); /* @[declare_mqttpropget_payloadformatindicator] */ /** @@ -2833,7 +2833,7 @@ MQTTStatus_t MQTTPropGet_PayloadFormatIndicator( MQTTPropBuilder_t * pPropertyBu */ /* @[declare_mqttpropget_messageexpiryinterval] */ MQTTStatus_t MQTTPropGet_MessageExpiryInterval( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pMessageExpiry ); /* @[declare_mqttpropget_messageexpiryinterval] */ @@ -2849,7 +2849,7 @@ MQTTStatus_t MQTTPropGet_MessageExpiryInterval( MQTTPropBuilder_t * pPropertyBui */ /* @[declare_mqttpropget_topicalias] */ MQTTStatus_t MQTTPropGet_TopicAlias( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint16_t * pTopicAlias ); /* @[declare_mqttpropget_topicalias] */ @@ -2866,9 +2866,9 @@ MQTTStatus_t MQTTPropGet_TopicAlias( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_responsetopic] */ MQTTStatus_t MQTTPropGet_ResponseTopic( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pResponseTopic, - uint16_t * pResponseTopicLength ); + size_t * pResponseTopicLength ); /* @[declare_mqttpropget_responsetopic] */ /** @@ -2884,9 +2884,9 @@ MQTTStatus_t MQTTPropGet_ResponseTopic( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_correlationdata] */ MQTTStatus_t MQTTPropGet_CorrelationData( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pCorrelationData, - uint16_t * pCorrelationDataLength ); + size_t * pCorrelationDataLength ); /* @[declare_mqttpropget_correlationdata] */ /** @@ -2901,7 +2901,7 @@ MQTTStatus_t MQTTPropGet_CorrelationData( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_subscriptionid] */ MQTTStatus_t MQTTPropGet_SubscriptionId( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, uint32_t * pSubscriptionId ); /* @[declare_mqttpropget_subscriptionid] */ @@ -2923,9 +2923,9 @@ MQTTStatus_t MQTTPropGet_SubscriptionId( MQTTPropBuilder_t * pPropertyBuilder, */ /* @[declare_mqttpropget_contenttype] */ MQTTStatus_t MQTTPropGet_ContentType( MQTTPropBuilder_t * pPropertyBuilder, - uint32_t * currentIndex, + size_t * currentIndex, const char ** pContentType, - uint16_t * pContentTypeLength ); + size_t * pContentTypeLength ); /* @[declare_mqttpropget_contenttype] */ /** @@ -3053,10 +3053,10 @@ MQTTStatus_t MQTT_ValidateUnsubscribeProperties( const MQTTPropBuilder_t * pProp * @endcode */ /* @[declare_mqtt_getackpacketsize] */ -MQTTStatus_t MQTT_GetAckPacketSize(size_t* pRemainingLength, - size_t* pPacketSize, - uint32_t maxPacketSize, - size_t ackPropertyLength); +MQTTStatus_t MQTT_GetAckPacketSize( uint32_t * pRemainingLength, + uint32_t * pPacketSize, + uint32_t maxPacketSize, + size_t ackPropertyLength); /* @[declare_mqtt_getackpacketsize] */ /** @@ -3072,7 +3072,7 @@ MQTTStatus_t MQTT_GetAckPacketSize(size_t* pRemainingLength, * - #MQTTSuccess , #MQTTBadParameter or #MQTTBadResponse. */ /* @[declare_mqtt_validatedisconnectproperties] */ -MQTTStatus_t MQTT_ValidateDisconnectProperties( uint32_t connectSessionExpiry, const MQTTPropBuilder_t * pPropertyBuilder); +MQTTStatus_t MQTT_ValidateDisconnectProperties( uint32_t connectSessionExpiry, const MQTTPropBuilder_t * pPropertyBuilder ); /* @[declare_mqtt_validatedisconnectproperties] */ /** diff --git a/source/include/private/core_mqtt_serializer_private.h b/source/include/private/core_mqtt_serializer_private.h index 270093339..e4c255467 100644 --- a/source/include/private/core_mqtt_serializer_private.h +++ b/source/include/private/core_mqtt_serializer_private.h @@ -307,6 +307,13 @@ */ #define MAX_VARIABLE_LENGTH_INT_VALUE ( ( uint32_t ) 268435455U ) +/** + * @brief A macro to check whether the size_t values will overflow when converted + * to uint16_t which is used to represent MQTT UTF8 strings. + */ +#define CHECK_SIZE_T_OVERFLOWS_16BIT( x ) \ + ( ( sizeof( size_t ) <= sizeof( uint16_t ) ) ? false : ( x > UINT16_MAX ) ) + /** * @fn size_t variableLengthEncodedSize( uint32_t length ); * @@ -346,7 +353,7 @@ uint8_t * encodeString( uint8_t * pDestination, /** @endcond */ /** - * @fn MQTTStatus_t decodeUserProp( const char ** pPropertyKey, uint16_t * pPropertyKeyLen, const char ** pPropertyValue, uint16_t * pPropertyValueLen, uint32_t * pPropertyLength, uint8_t ** pIndex ); + * @fn MQTTStatus_t decodeUserProp( const char ** pPropertyKey, size_t * pPropertyKeyLen, const char ** pPropertyValue, size_t * pPropertyValueLen, uint32_t * pPropertyLength, uint8_t ** pIndex ); * * @brief Validate the length and decode a user property. * @@ -365,9 +372,9 @@ uint8_t * encodeString( uint8_t * pDestination, * Doxygen should ignore this definition, this function is private. */ MQTTStatus_t decodeUserProp( const char ** pPropertyKey, - uint16_t * pPropertyKeyLen, + size_t * pPropertyKeyLen, const char ** pPropertyValue, - uint16_t * pPropertyValueLen, + size_t * pPropertyValueLen, uint32_t * pPropertyLength, uint8_t ** pIndex ); /** @endcond */ @@ -463,7 +470,7 @@ uint8_t * encodeVariableLength( uint8_t * pDestination, /** @endcond */ /** - * @fn MQTTStatus_t decodeUtf8( const char ** pProperty, uint16_t * pLength, uint32_t * pPropertyLength, bool * pUsed, uint8_t ** pIndex ); + * @fn MQTTStatus_t decodeUtf8( const char ** pProperty, size_t * pLength, uint32_t * pPropertyLength, bool * pUsed, uint8_t ** pIndex ); * * @brief Validate the length and decode a utf 8 string. * @@ -481,7 +488,7 @@ uint8_t * encodeVariableLength( uint8_t * pDestination, * Doxygen should ignore this definition, this function is private. */ MQTTStatus_t decodeUtf8( const char ** pProperty, - uint16_t * pLength, + size_t * pLength, uint32_t * pPropertyLength, bool * pUsed, uint8_t ** pIndex ); @@ -511,7 +518,7 @@ MQTTStatus_t decodeVariableLength( const uint8_t * pBuffer, /** @endcond */ /** - * @fn uint8_t * serializeAckFixed( uint8_t * pIndex, uint8_t packetType, uint16_t packetId, size_t remainingLength, MQTTSuccessFailReasonCode_t reasonCode ); + * @fn uint8_t * serializeAckFixed( uint8_t * pIndex, uint8_t packetType, uint16_t packetId, uint32_t remainingLength, MQTTSuccessFailReasonCode_t reasonCode ); * * @brief Serialize the fixed size part of the ack packet header. * @@ -532,7 +539,7 @@ MQTTStatus_t decodeVariableLength( const uint8_t * pBuffer, uint8_t * serializeAckFixed( uint8_t * pIndex, uint8_t packetType, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, MQTTSuccessFailReasonCode_t reasonCode ); /** @endcond */ @@ -559,7 +566,7 @@ MQTTStatus_t decodeSubackPropertyLength( const uint8_t * pIndex, /** @endcond */ /** - * @fn uint8_t * serializeDisconnectFixed( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, size_t remainingLength ); + * @fn uint8_t * serializeDisconnectFixed( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, uint32_t remainingLength ); * * @brief Serialize the fixed size part of the disconnect packet header. * @@ -576,7 +583,7 @@ MQTTStatus_t decodeSubackPropertyLength( const uint8_t * pIndex, */ uint8_t * serializeDisconnectFixed( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength ); + uint32_t remainingLength ); /** @endcond */ /** @@ -604,7 +611,7 @@ uint8_t * serializeConnectFixedHeader( uint8_t * pIndex, /** @endcond */ /** - * @fn uint8_t * serializeSubscribeHeader( size_t remainingLength, uint8_t * pIndex, uint16_t packetId ); + * @fn uint8_t * serializeSubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ); * @brief Serialize the fixed part of the subscribe packet header. * * @param[in] remainingLength The remaining length of the packet to be @@ -620,13 +627,13 @@ uint8_t * serializeConnectFixedHeader( uint8_t * pIndex, * @cond DOXYGEN_IGNORE * Doxygen should ignore this definition, this function is private. */ -uint8_t * serializeSubscribeHeader( size_t remainingLength, +uint8_t * serializeSubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ); /** @endcond */ /** - * @fn uint8_t * serializeUnsubscribeHeader( size_t remainingLength, uint8_t * pIndex, uint16_t packetId ); + * @fn uint8_t * serializeUnsubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ); * @brief Serialize the fixed part of the unsubscribe packet header. * * @param[in] remainingLength The remaining length of the packet to be @@ -642,7 +649,7 @@ uint8_t * serializeSubscribeHeader( size_t remainingLength, * @cond DOXYGEN_IGNORE * Doxygen should ignore this definition, this function is private. */ -uint8_t * serializeUnsubscribeHeader( size_t remainingLength, +uint8_t * serializeUnsubscribeHeader( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId ); /** @endcond */ diff --git a/test/cbmc/proofs/DecodePubAckProperties/DecodePubAckProperties_harness.c b/test/cbmc/proofs/DecodePubAckProperties/DecodePubAckProperties_harness.c index 9128e074a..d657427aa 100644 --- a/test/cbmc/proofs/DecodePubAckProperties/DecodePubAckProperties_harness.c +++ b/test/cbmc/proofs/DecodePubAckProperties/DecodePubAckProperties_harness.c @@ -51,7 +51,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * packetBytes; - size_t remainingLength; + uint32_t remainingLength; size_t propertyLength; propBuffer = allocateMqttPropBuilder( NULL ); diff --git a/test/cbmc/proofs/DeserializeHelpers/DeserializeHelpers_harness.c b/test/cbmc/proofs/DeserializeHelpers/DeserializeHelpers_harness.c index 9e66c48fd..9bea5ddde 100644 --- a/test/cbmc/proofs/DeserializeHelpers/DeserializeHelpers_harness.c +++ b/test/cbmc/proofs/DeserializeHelpers/DeserializeHelpers_harness.c @@ -64,7 +64,7 @@ void harness() __CPROVER_assume( *buffer != NULL ); const char * pPropertyKey, * pPropertyValue; - uint16_t PropertyKeyLen, PropertyValueLen; + size_t PropertyKeyLen, PropertyValueLen; decodeUserProp( &pPropertyKey, &PropertyKeyLen, @@ -97,7 +97,7 @@ void harness() __CPROVER_assume( *buffer != NULL ); const char * pProperty; - uint16_t PropertyLen; + size_t PropertyLen; decodeUtf8( &pProperty, &PropertyLen, length, diff --git a/test/cbmc/proofs/DeserializePublishProperties/DeserializePublishProperties_harness.c b/test/cbmc/proofs/DeserializePublishProperties/DeserializePublishProperties_harness.c index dd7157c13..307de8672 100644 --- a/test/cbmc/proofs/DeserializePublishProperties/DeserializePublishProperties_harness.c +++ b/test/cbmc/proofs/DeserializePublishProperties/DeserializePublishProperties_harness.c @@ -54,12 +54,13 @@ void harness() size_t propertyLength; size_t maxPropertyLength; size_t minRemainingLength; - size_t remainingLength; + uint32_t remainingLength; pPublishInfo = allocateMqttPublishInfo( NULL ); __CPROVER_assume( isValidMqttPublishInfo( pPublishInfo ) ); __CPROVER_assume( pPublishInfo != NULL ); __CPROVER_assume( pPublishInfo->topicNameLength != 0 ); + __CPROVER_assume( pPublishInfo->topicNameLength <= UINT16_MAX ); propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_AssignedClientId/MQTTPropGet_AssignedClientId_harness.c b/test/cbmc/proofs/MQTTPropGet_AssignedClientId/MQTTPropGet_AssignedClientId_harness.c index 91db8ba19..77ec0de91 100644 --- a/test/cbmc/proofs/MQTTPropGet_AssignedClientId/MQTTPropGet_AssignedClientId_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_AssignedClientId/MQTTPropGet_AssignedClientId_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPropBuilder_t * propBuffer; char ** pClientId; - uint16_t * clientIdLength; - uint32_t currentIndex; + size_t * clientIdLength; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } pClientId = malloc( sizeof( char * ) ); - clientIdLength = malloc( sizeof( uint16_t ) ); + clientIdLength = malloc( sizeof( size_t ) ); MQTTPropGet_AssignedClientId( propBuffer, ¤tIndex, pClientId, clientIdLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_AuthData/MQTTPropGet_AuthData_harness.c b/test/cbmc/proofs/MQTTPropGet_AuthData/MQTTPropGet_AuthData_harness.c index d14e6f284..3d94372cb 100644 --- a/test/cbmc/proofs/MQTTPropGet_AuthData/MQTTPropGet_AuthData_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_AuthData/MQTTPropGet_AuthData_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPropBuilder_t * propBuffer; char ** pAuthData; - uint16_t * authDataLength; - uint32_t currentIndex; + size_t * authDataLength; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } pAuthData = malloc( sizeof( char * ) ); - authDataLength = malloc( sizeof( uint16_t ) ); + authDataLength = malloc( sizeof( size_t ) ); MQTTPropGet_AuthData( propBuffer, ¤tIndex, pAuthData, authDataLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_AuthMethod/MQTTPropGet_AuthMethod_harness.c b/test/cbmc/proofs/MQTTPropGet_AuthMethod/MQTTPropGet_AuthMethod_harness.c index 5c8ff1328..4e0708f60 100644 --- a/test/cbmc/proofs/MQTTPropGet_AuthMethod/MQTTPropGet_AuthMethod_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_AuthMethod/MQTTPropGet_AuthMethod_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPropBuilder_t * propBuffer; char ** pAuthMethod; - uint16_t * authMethodLength; - uint32_t currentIndex; + size_t * authMethodLength; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } pAuthMethod = malloc( sizeof( char * ) ); - authMethodLength = malloc( sizeof( uint16_t ) ); + authMethodLength = malloc( sizeof( size_t ) ); MQTTPropGet_AuthMethod( propBuffer, ¤tIndex, pAuthMethod, authMethodLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_ContentType/MQTTPropGet_ContentType_harness.c b/test/cbmc/proofs/MQTTPropGet_ContentType/MQTTPropGet_ContentType_harness.c index f80e0364a..b4f5c7093 100644 --- a/test/cbmc/proofs/MQTTPropGet_ContentType/MQTTPropGet_ContentType_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ContentType/MQTTPropGet_ContentType_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPropBuilder_t * propBuffer; char ** pContentType; - uint16_t * contentTypeLength; - uint32_t currentIndex; + size_t * contentTypeLength; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } pContentType = malloc( sizeof( char * ) ); - contentTypeLength = malloc( sizeof( uint16_t ) ); + contentTypeLength = malloc( sizeof( size_t ) ); MQTTPropGet_ContentType( propBuffer, ¤tIndex, pContentType, contentTypeLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_CorrelationData/MQTTPropGet_CorrelationData_harness.c b/test/cbmc/proofs/MQTTPropGet_CorrelationData/MQTTPropGet_CorrelationData_harness.c index f40c06ce4..639b4cc34 100644 --- a/test/cbmc/proofs/MQTTPropGet_CorrelationData/MQTTPropGet_CorrelationData_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_CorrelationData/MQTTPropGet_CorrelationData_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPropBuilder_t * propBuffer; char ** correlationData; - uint16_t * correlationLength; - uint32_t currentIndex; + size_t * correlationLength; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } correlationData = malloc( sizeof( char * ) ); - correlationLength = malloc( sizeof( uint16_t ) ); + correlationLength = malloc( sizeof( size_t ) ); MQTTPropGet_CorrelationData( propBuffer, ¤tIndex, correlationData, correlationLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_MaxPacketSize/MQTTPropGet_MaxPacketSize_harness.c b/test/cbmc/proofs/MQTTPropGet_MaxPacketSize/MQTTPropGet_MaxPacketSize_harness.c index 789a15b60..d64ad0d21 100644 --- a/test/cbmc/proofs/MQTTPropGet_MaxPacketSize/MQTTPropGet_MaxPacketSize_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_MaxPacketSize/MQTTPropGet_MaxPacketSize_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint32_t * maxPacketSize; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_MaxQos/MQTTPropGet_MaxQos_harness.c b/test/cbmc/proofs/MQTTPropGet_MaxQos/MQTTPropGet_MaxQos_harness.c index 0fd5a7bfe..5fc11921b 100644 --- a/test/cbmc/proofs/MQTTPropGet_MaxQos/MQTTPropGet_MaxQos_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_MaxQos/MQTTPropGet_MaxQos_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * maxQos; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_MessageExpiryInterval/MQTTPropGet_MessageExpiryInterval_harness.c b/test/cbmc/proofs/MQTTPropGet_MessageExpiryInterval/MQTTPropGet_MessageExpiryInterval_harness.c index 451e22b24..2367bc0d6 100644 --- a/test/cbmc/proofs/MQTTPropGet_MessageExpiryInterval/MQTTPropGet_MessageExpiryInterval_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_MessageExpiryInterval/MQTTPropGet_MessageExpiryInterval_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint32_t * msgExpiryInterval; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_PayloadFormatIndicator/MQTTPropGet_PayloadFormatIndicator_harness.c b/test/cbmc/proofs/MQTTPropGet_PayloadFormatIndicator/MQTTPropGet_PayloadFormatIndicator_harness.c index 4dc32191c..4434a1783 100644 --- a/test/cbmc/proofs/MQTTPropGet_PayloadFormatIndicator/MQTTPropGet_PayloadFormatIndicator_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_PayloadFormatIndicator/MQTTPropGet_PayloadFormatIndicator_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * payloadFormat; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_ReasonString/MQTTPropGet_ReasonString_harness.c b/test/cbmc/proofs/MQTTPropGet_ReasonString/MQTTPropGet_ReasonString_harness.c index b3e9d6d8b..1b546c07d 100644 --- a/test/cbmc/proofs/MQTTPropGet_ReasonString/MQTTPropGet_ReasonString_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ReasonString/MQTTPropGet_ReasonString_harness.c @@ -34,7 +34,7 @@ void harness() MQTTPropBuilder_t * propBuffer; char ** pReasonString; uint16_t * reasonStringLength; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_ReceiveMax/MQTTPropGet_ReceiveMax_harness.c b/test/cbmc/proofs/MQTTPropGet_ReceiveMax/MQTTPropGet_ReceiveMax_harness.c index be15ef6e1..51bbd9dc7 100644 --- a/test/cbmc/proofs/MQTTPropGet_ReceiveMax/MQTTPropGet_ReceiveMax_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ReceiveMax/MQTTPropGet_ReceiveMax_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint16_t * receiveMax; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_ResponseInfo/MQTTPropGet_ResponseInfo_harness.c b/test/cbmc/proofs/MQTTPropGet_ResponseInfo/MQTTPropGet_ResponseInfo_harness.c index 48ccd0e49..8c51d2112 100644 --- a/test/cbmc/proofs/MQTTPropGet_ResponseInfo/MQTTPropGet_ResponseInfo_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ResponseInfo/MQTTPropGet_ResponseInfo_harness.c @@ -34,7 +34,7 @@ void harness() MQTTPropBuilder_t * propBuffer; char ** pResponseInfo; uint16_t * responseInfoLength; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } pResponseInfo = malloc( sizeof( char * ) ); - responseInfoLength = malloc( sizeof( uint16_t ) ); + responseInfoLength = malloc( sizeof( size_t ) ); MQTTPropGet_ResponseInfo( propBuffer, ¤tIndex, pResponseInfo, responseInfoLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_ResponseTopic/MQTTPropGet_ResponseTopic_harness.c b/test/cbmc/proofs/MQTTPropGet_ResponseTopic/MQTTPropGet_ResponseTopic_harness.c index af5cbb227..854048dbe 100644 --- a/test/cbmc/proofs/MQTTPropGet_ResponseTopic/MQTTPropGet_ResponseTopic_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ResponseTopic/MQTTPropGet_ResponseTopic_harness.c @@ -34,7 +34,7 @@ void harness() MQTTPropBuilder_t * propBuffer; char ** responseTopic; uint16_t * responseTopicLength; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); @@ -47,7 +47,7 @@ void harness() } responseTopic = malloc( sizeof( char * ) ); - responseTopicLength = malloc( sizeof( uint16_t ) ); + responseTopicLength = malloc( sizeof( size_t ) ); MQTTPropGet_ResponseTopic( propBuffer, ¤tIndex, responseTopic, responseTopicLength ); } diff --git a/test/cbmc/proofs/MQTTPropGet_RetainAvailable/MQTTPropGet_RetainAvailable_harness.c b/test/cbmc/proofs/MQTTPropGet_RetainAvailable/MQTTPropGet_RetainAvailable_harness.c index ed07d7a48..e089cf14a 100644 --- a/test/cbmc/proofs/MQTTPropGet_RetainAvailable/MQTTPropGet_RetainAvailable_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_RetainAvailable/MQTTPropGet_RetainAvailable_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * retainAvailable; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_ServerKeepAlive/MQTTPropGet_ServerKeepAlive_harness.c b/test/cbmc/proofs/MQTTPropGet_ServerKeepAlive/MQTTPropGet_ServerKeepAlive_harness.c index 0bd967014..0004c1ae5 100644 --- a/test/cbmc/proofs/MQTTPropGet_ServerKeepAlive/MQTTPropGet_ServerKeepAlive_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ServerKeepAlive/MQTTPropGet_ServerKeepAlive_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint16_t * serverKeepAlive; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_ServerRef/MQTTPropGet_ServerRef_harness.c b/test/cbmc/proofs/MQTTPropGet_ServerRef/MQTTPropGet_ServerRef_harness.c index ddf487e0a..d61e71c04 100644 --- a/test/cbmc/proofs/MQTTPropGet_ServerRef/MQTTPropGet_ServerRef_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_ServerRef/MQTTPropGet_ServerRef_harness.c @@ -34,7 +34,7 @@ void harness() MQTTPropBuilder_t * propBuffer; char ** pServerRef; uint16_t * serverRefLength; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_SessionExpiry/MQTTPropGet_SessionExpiry_harness.c b/test/cbmc/proofs/MQTTPropGet_SessionExpiry/MQTTPropGet_SessionExpiry_harness.c index 5e63026b9..40686f8c0 100644 --- a/test/cbmc/proofs/MQTTPropGet_SessionExpiry/MQTTPropGet_SessionExpiry_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_SessionExpiry/MQTTPropGet_SessionExpiry_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint32_t * sessionExpiry; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_SharedSubAvailable/MQTTPropGet_SharedSubAvailable_harness.c b/test/cbmc/proofs/MQTTPropGet_SharedSubAvailable/MQTTPropGet_SharedSubAvailable_harness.c index 6df0748b7..97f20f959 100644 --- a/test/cbmc/proofs/MQTTPropGet_SharedSubAvailable/MQTTPropGet_SharedSubAvailable_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_SharedSubAvailable/MQTTPropGet_SharedSubAvailable_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * isSharedSubAvailable; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_SubsIdAvailable/MQTTPropGet_SubsIdAvailable_harness.c b/test/cbmc/proofs/MQTTPropGet_SubsIdAvailable/MQTTPropGet_SubsIdAvailable_harness.c index 53718d215..17481a264 100644 --- a/test/cbmc/proofs/MQTTPropGet_SubsIdAvailable/MQTTPropGet_SubsIdAvailable_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_SubsIdAvailable/MQTTPropGet_SubsIdAvailable_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * isSubIdAvailable; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_SubscriptionId/MQTTPropGet_SubscriptionId_harness.c b/test/cbmc/proofs/MQTTPropGet_SubscriptionId/MQTTPropGet_SubscriptionId_harness.c index a6f53fa02..5109f2712 100644 --- a/test/cbmc/proofs/MQTTPropGet_SubscriptionId/MQTTPropGet_SubscriptionId_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_SubscriptionId/MQTTPropGet_SubscriptionId_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; size_t * subscriptionId; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_TopicAlias/MQTTPropGet_TopicAlias_harness.c b/test/cbmc/proofs/MQTTPropGet_TopicAlias/MQTTPropGet_TopicAlias_harness.c index 33d0b0e09..e4ad7d1ec 100644 --- a/test/cbmc/proofs/MQTTPropGet_TopicAlias/MQTTPropGet_TopicAlias_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_TopicAlias/MQTTPropGet_TopicAlias_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint16_t * topicAlias; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_TopicAliasMax/MQTTPropGet_TopicAliasMax_harness.c b/test/cbmc/proofs/MQTTPropGet_TopicAliasMax/MQTTPropGet_TopicAliasMax_harness.c index 34f4bc61d..2d0bdbc77 100644 --- a/test/cbmc/proofs/MQTTPropGet_TopicAliasMax/MQTTPropGet_TopicAliasMax_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_TopicAliasMax/MQTTPropGet_TopicAliasMax_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint16_t * topicAliasMax; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTTPropGet_UserProp/MQTTPropGet_UserProp_harness.c b/test/cbmc/proofs/MQTTPropGet_UserProp/MQTTPropGet_UserProp_harness.c index 2776ea408..d97c498b8 100644 --- a/test/cbmc/proofs/MQTTPropGet_UserProp/MQTTPropGet_UserProp_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_UserProp/MQTTPropGet_UserProp_harness.c @@ -32,7 +32,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; - uint32_t currentIndex; + size_t currentIndex; MQTTUserProperty_t pUserProperty; propBuffer = allocateMqttPropBuilder( NULL ); diff --git a/test/cbmc/proofs/MQTTPropGet_WildcardId/MQTTPropGet_WildcardId_harness.c b/test/cbmc/proofs/MQTTPropGet_WildcardId/MQTTPropGet_WildcardId_harness.c index 1bfb81d48..4b9a6c720 100644 --- a/test/cbmc/proofs/MQTTPropGet_WildcardId/MQTTPropGet_WildcardId_harness.c +++ b/test/cbmc/proofs/MQTTPropGet_WildcardId/MQTTPropGet_WildcardId_harness.c @@ -33,7 +33,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * isWildCardAvailable; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c b/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c index 7f31b9451..df362f934 100644 --- a/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c +++ b/test/cbmc/proofs/MQTT_Connect/MQTT_Connect_harness.c @@ -63,7 +63,7 @@ static uint32_t ulGetTimeFunction( void ) uint8_t * serializeConnectFixedHeader( uint8_t * pIndex, const MQTTConnectInfo_t * pConnectInfo, const MQTTPublishInfo_t * pWillInfo, - size_t remainingLength ) + uint32_t remainingLength ) { __CPROVER_assert( pIndex != NULL, "pIndex must not be NULL." ); __CPROVER_assert( pConnectInfo != NULL, "pConnectInfo must not be NULL." ); diff --git a/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c b/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c index 043fdc3b5..62c79bbf6 100644 --- a/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c +++ b/test/cbmc/proofs/MQTT_DeserializeAck/MQTT_DeserializeAck_harness.c @@ -42,7 +42,7 @@ MQTTStatus_t __CPROVER_file_local_core_mqtt_serializer_c_deserializeConnackPrope MQTTStatus_t __CPROVER_file_local_core_mqtt_serializer_c_deserializeSubUnsubAckProperties( MQTTPropBuilder_t * propBuffer, uint8_t * pIndex, size_t * pSubackPropertyLength, - size_t remainingLength ) + uint32_t remainingLength ) { MQTTStatus_t status; @@ -51,7 +51,7 @@ MQTTStatus_t __CPROVER_file_local_core_mqtt_serializer_c_deserializeSubUnsubAckP MQTTStatus_t __CPROVER_file_local_core_mqtt_serializer_c_decodePubAckProperties( MQTTPropBuilder_t * propBuffer, uint8_t * pIndex, - size_t remainingLength ) + uint32_t remainingLength ) { MQTTStatus_t status; diff --git a/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c b/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c index 5998aa657..f3ca9021d 100644 --- a/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c +++ b/test/cbmc/proofs/MQTT_DeserializePublish/MQTT_DeserializePublish_harness.c @@ -35,12 +35,12 @@ MQTTStatus_t __CPROVER_file_local_core_mqtt_serializer_c_deserializePublishPrope MQTTPropBuilder_t * propBuffer, uint8_t * pIndex, uint16_t topicAliasMax, - size_t remainingLength ) + uint32_t remainingLength ) { MQTTStatus_t status; size_t propertyLength = 0U; uint8_t * pLocalIndex = pIndex; - size_t remainingLengthForProperties; + uint32_t remainingLengthForProperties; remainingLengthForProperties = remainingLength; remainingLengthForProperties -= pPublishInfo->topicNameLength + sizeof( uint16_t ); diff --git a/test/cbmc/proofs/MQTT_GetNextPropertyType/MQTT_GetNextPropertyType_harness.c b/test/cbmc/proofs/MQTT_GetNextPropertyType/MQTT_GetNextPropertyType_harness.c index c3388978c..5541b8949 100644 --- a/test/cbmc/proofs/MQTT_GetNextPropertyType/MQTT_GetNextPropertyType_harness.c +++ b/test/cbmc/proofs/MQTT_GetNextPropertyType/MQTT_GetNextPropertyType_harness.c @@ -34,7 +34,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; uint8_t * propertyId; - uint32_t * currentIndex = malloc( sizeof( uint32_t ) ); + size_t * currentIndex = malloc( sizeof( size_t ) ); propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c b/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c index 5ff3c296d..0703f0fa0 100644 --- a/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c +++ b/test/cbmc/proofs/MQTT_ProcessLoop/MQTT_ProcessLoop_harness.c @@ -54,7 +54,7 @@ MQTTStatus_t MQTT_DeserializePublish( const MQTTPacketInfo_t * pIncomingPacket, MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProperties, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t result; @@ -73,8 +73,8 @@ MQTTStatus_t MQTT_DeserializeDisconnect( const MQTTPacketInfo_t * pPacket, } MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnectProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, MQTTSuccessFailReasonCode_t * pReasonCode ) { diff --git a/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c b/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c index 5a5be04cd..97e75665f 100644 --- a/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c +++ b/test/cbmc/proofs/MQTT_ReceiveLoop/MQTT_ReceiveLoop_harness.c @@ -54,7 +54,7 @@ MQTTStatus_t MQTT_DeserializePublish( const MQTTPacketInfo_t * pIncomingPacket, MQTTStatus_t MQTT_SerializeDisconnect( const MQTTPropBuilder_t * pDisconnectProperties, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, const MQTTFixedBuffer_t * pFixedBuffer ) { MQTTStatus_t result; @@ -73,8 +73,8 @@ MQTTStatus_t MQTT_DeserializeDisconnect( const MQTTPacketInfo_t * pPacket, } MQTTStatus_t MQTT_GetDisconnectPacketSize( const MQTTPropBuilder_t * pDisconnectProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, MQTTSuccessFailReasonCode_t * pReasonCode ) { diff --git a/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c b/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c index 237043bee..63b9284d7 100644 --- a/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c +++ b/test/cbmc/proofs/MQTT_SerializeDisconnect/MQTT_SerializeDisconnect_harness.c @@ -35,8 +35,8 @@ void harness() MQTTPropBuilder_t * pDisconnectProperties; MQTTSuccessFailReasonCode_t * reasonCode = NULL; MQTTStatus_t status; - size_t remainingLength; - size_t packetSize; + uint32_t remainingLength; + uint32_t packetSize; uint32_t maxPacketSize; pDisconnectProperties = allocateMqttPropBuilder( NULL ); diff --git a/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c b/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c index ca6c163bf..16eb1b9c8 100644 --- a/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c +++ b/test/cbmc/proofs/MQTT_SerializePublish/MQTT_SerializePublish_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPublishInfo_t * pPublishInfo; uint16_t packetId; - size_t remainingLength; - size_t packetSize; + uint32_t remainingLength; + uint32_t packetSize; const MQTTFixedBuffer_t * pFixedBuffer; MQTTPropBuilder_t * pPublishProperties; MQTTStatus_t status = MQTTSuccess; diff --git a/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c b/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c index da4bb26cc..6323a20f7 100644 --- a/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c +++ b/test/cbmc/proofs/MQTT_SerializePublishHeader/MQTT_SerializePublishHeader_harness.c @@ -33,8 +33,8 @@ void harness() { MQTTPublishInfo_t * pPublishInfo; uint16_t packetId; - size_t remainingLength; - size_t packetSize; + uint32_t remainingLength; + uint32_t packetSize; MQTTFixedBuffer_t * pFixedBuffer; size_t * pHeaderSize; MQTTPropBuilder_t * pPublishProperties; diff --git a/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c b/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c index 1cb265634..9c00e7f54 100644 --- a/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c +++ b/test/cbmc/proofs/MQTT_SerializeSubscribe/MQTT_SerializeSubscribe_harness.c @@ -33,9 +33,9 @@ void harness() { MQTTSubscribeInfo_t * pSubscriptionList; size_t subscriptionCount; - size_t remainingLength; + uint32_t remainingLength; uint16_t packetId; - size_t packetSize; + uint32_t packetSize; MQTTFixedBuffer_t * pFixedBuffer; MQTTStatus_t status = MQTTSuccess; MQTTPropBuilder_t * pSubscribeProperties; diff --git a/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c b/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c index e518b7d2d..3cf653b56 100644 --- a/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c +++ b/test/cbmc/proofs/MQTT_SerializeUnsubscribe/MQTT_SerializeUnsubscribe_harness.c @@ -33,14 +33,14 @@ void harness() { MQTTSubscribeInfo_t * pSubscriptionList; size_t subscriptionCount; - size_t remainingLength; + uint32_t remainingLength; uint16_t packetId; MQTTPropBuilder_t * pUnsubscribeProperties; uint32_t maxPacketSize; /* This variable is not used but is needed for MQTT_GetUnsubscribePacketSize() * to verify the pSubscriptionList. */ - size_t packetSize; + uint32_t packetSize; MQTTFixedBuffer_t * pFixedBuffer; MQTTStatus_t status = MQTTSuccess; diff --git a/test/cbmc/proofs/MQTT_SkipNextProperty/MQTT_SkipNextProperty_harness.c b/test/cbmc/proofs/MQTT_SkipNextProperty/MQTT_SkipNextProperty_harness.c index 841b35a8d..f41cbdb85 100644 --- a/test/cbmc/proofs/MQTT_SkipNextProperty/MQTT_SkipNextProperty_harness.c +++ b/test/cbmc/proofs/MQTT_SkipNextProperty/MQTT_SkipNextProperty_harness.c @@ -32,7 +32,7 @@ void harness() { MQTTPropBuilder_t * propBuffer; - uint32_t currentIndex; + size_t currentIndex; propBuffer = allocateMqttPropBuilder( NULL ); __CPROVER_assume( isValidMqttPropBuilder( propBuffer ) ); diff --git a/test/cbmc/proofs/deserializeSubUnsubAckProperties/deserializeSubUnsubAckProperties_harness.c b/test/cbmc/proofs/deserializeSubUnsubAckProperties/deserializeSubUnsubAckProperties_harness.c index a90f952ab..9e9145e97 100644 --- a/test/cbmc/proofs/deserializeSubUnsubAckProperties/deserializeSubUnsubAckProperties_harness.c +++ b/test/cbmc/proofs/deserializeSubUnsubAckProperties/deserializeSubUnsubAckProperties_harness.c @@ -50,7 +50,7 @@ void harness() MQTTPropBuilder_t * propBuffer; uint8_t * packetBytes; size_t propertyLength; - size_t remainingLength; + uint32_t remainingLength; size_t minRemainingLength; propBuffer = allocateMqttPropBuilder( NULL ); diff --git a/test/unit-test/core_mqtt_serializer_utest.c b/test/unit-test/core_mqtt_serializer_utest.c index f91bd1b07..85536e542 100644 --- a/test/unit-test/core_mqtt_serializer_utest.c +++ b/test/unit-test/core_mqtt_serializer_utest.c @@ -331,7 +331,7 @@ static size_t encodeVariableLengthUT( uint8_t * pDestination, { uint8_t lengthByte; uint8_t * pLengthEnd = NULL; - size_t remainingLength = length; + uint32_t remainingLength = length; TEST_ASSERT_NOT_NULL( pDestination ); @@ -1303,6 +1303,12 @@ void test_MQTT_SerializeConnect( void ) memset( &connectInfo, 0x0, sizeof( connectInfo ) ); status = MQTT_SerializeConnect( &connectInfo, NULL, NULL, NULL, 120, &fixedBuffer ); + TEST_ASSERT_EQUAL_INT( MQTTBadParameter, status ); + + memset( &connectInfo, 0x0, sizeof( connectInfo ) ); + connectInfo.pClientIdentifier = "TEST"; + connectInfo.clientIdentifierLength = 4; + status = MQTT_SerializeConnect( &connectInfo, NULL, NULL, NULL, 120, &fixedBuffer ); TEST_ASSERT_EQUAL_INT( MQTTNoMemory, status ); /* Create a good connection info. */ @@ -1455,8 +1461,8 @@ void test_MQTT_SerializeConnect( void ) void test_RemaininglengthLimit( void ) { /* Test will property length more than the max value allowed. */ - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; uint32_t maxPacketSize = 100; MQTTStatus_t status = MQTTSuccess; @@ -1542,8 +1548,8 @@ void test_MQTTV5_ValidatePublishParams() void test_MQTTV5_GetPublishPacketSize() { - size_t remainingLength = 0U; - size_t packetSize = 0U; + uint32_t remainingLength = 0U; + uint32_t packetSize = 0U; uint32_t maxPacketSize = 0U; setupPublishInfo( &publishInfo ); @@ -1629,10 +1635,10 @@ void test_MQTTV5_GetPublishPacketSize() void test_MQTT_SerializePublish( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 98; + uint32_t remainingLength = 98; uint8_t buffer[ 200 + 2 * BUFFER_PADDING_LENGTH ]; size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH; - size_t packetSize = bufferSize; + uint32_t packetSize = bufferSize; MQTTStatus_t status = MQTTSuccess; MQTTFixedBuffer_t fixedBuffer = { .pBuffer = &buffer[ BUFFER_PADDING_LENGTH ], .size = bufferSize }; uint8_t expectedPacket[ 200 ]; @@ -2066,8 +2072,8 @@ void test_MQTTV5_DeserializeAck_Pubrel() void test_MQTTV5_GetAckPacketSize() { MQTTStatus_t status; - size_t remainingLength; - size_t packetSize; + uint32_t remainingLength; + uint32_t packetSize; uint32_t maxPacketSize = 0U; /*Invalid parameters*/ @@ -2111,8 +2117,8 @@ void test_MQTTV5_GetAckPacketSize() void test_MQTTV5_GetDisconnectPacketSize() { - size_t remainingLength; - size_t packetSize; + uint32_t remainingLength; + uint32_t packetSize; uint32_t maxPacketSize = 0U; MQTTStatus_t status; MQTTSuccessFailReasonCode_t reasonCode; @@ -2310,8 +2316,8 @@ void test_MQTTV5_GetSubscribePacketSize( void ) { MQTTStatus_t status = MQTTSuccess; MQTTSubscribeInfo_t subscribeInfo; - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; /** Verify Parameters */ @@ -2334,8 +2340,8 @@ void test_MQTTV5_GetSubscribePacketSize_HappyPath( void ) { MQTTStatus_t status = MQTTSuccess; MQTTSubscribeInfo_t subscribeInfo; - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; subscribeInfo.pTopicFilter = TEST_TOPIC_NAME; subscribeInfo.topicFilterLength = TEST_TOPIC_NAME_LENGTH; @@ -2366,8 +2372,8 @@ void test_MQTTV5_GetSubscribePacketSize_MultipleSubscriptions( void ) { MQTTStatus_t status = MQTTSuccess; MQTTSubscribeInfo_t subscribeInfo[ 2 ]; - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; subscribeInfo[ 0 ].pTopicFilter = TEST_TOPIC_NAME; subscribeInfo[ 0 ].topicFilterLength = TEST_TOPIC_NAME_LENGTH; @@ -2390,8 +2396,8 @@ void test_MQTTV5_GetSubscribePacketSize_MultipleSubscriptions( void ) void test_calculateSubscriptionPacketSizeV5( void ) { size_t subscriptionCount = 1; - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; MQTTStatus_t status = MQTTSuccess; MQTTSubscribeInfo_t fourThousandSubscriptions[ 4096 ] = { 0 }; int i; @@ -2421,10 +2427,10 @@ void test_MQTT_SerializeSubscribe( void ) { MQTTSubscribeInfo_t subscriptionList; size_t subscriptionCount = 1; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 25 + 2 * BUFFER_PADDING_LENGTH ]; size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH; - size_t packetSize = bufferSize; + uint32_t packetSize = bufferSize; MQTTStatus_t status = MQTTSuccess; MQTTFixedBuffer_t fixedBuffer = { .pBuffer = &buffer[ BUFFER_PADDING_LENGTH ], .size = bufferSize }; uint8_t expectedPacket[ 100 ]; @@ -2638,10 +2644,10 @@ void test_MQTT_SerializeUnsubscribe( void ) { MQTTSubscribeInfo_t subscriptionList; size_t subscriptionCount = 1; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 33 + 2 * BUFFER_PADDING_LENGTH ]; size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH; - size_t packetSize = bufferSize; + uint32_t packetSize = bufferSize; MQTTStatus_t status = MQTTSuccess; MQTTFixedBuffer_t fixedBuffer = { .pBuffer = &buffer[ BUFFER_PADDING_LENGTH ], .size = bufferSize }; uint8_t expectedPacket[ 100 ]; @@ -2878,8 +2884,8 @@ void test_MQTTV5_GetUnsubscribePacketSize( void ) { MQTTStatus_t status = MQTTSuccess; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = 0; - size_t packetSize = 0; + uint32_t remainingLength = 0; + uint32_t packetSize = 0; status = MQTT_GetUnsubscribePacketSize( NULL, 1, NULL, &remainingLength, &packetSize, MQTT_MAX_PACKET_SIZE ); TEST_ASSERT_EQUAL_INT( MQTTBadParameter, status ); @@ -3163,12 +3169,12 @@ void test_MQTT_SerializeDisconnect( void ) { uint8_t buffer[ 25 + 2 * BUFFER_PADDING_LENGTH ]; size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH; - size_t packetSize = bufferSize; + uint32_t packetSize = bufferSize; MQTTFixedBuffer_t fixedBuffer = { .pBuffer = &buffer[ BUFFER_PADDING_LENGTH ], .size = bufferSize }; uint8_t expectedPacket[ 10 ] = { 0 }; uint8_t * pIterator = expectedPacket; MQTTStatus_t status = MQTTSuccess; - size_t remainingLength = 0; + uint32_t remainingLength = 0; /* Buffer size less than disconnect request fails. */ fixedBuffer.size = 1; @@ -3246,7 +3252,7 @@ void test_MQTT_SerializeDisconnect( void ) void test_MQTT_GetPingreqPacketSize( void ) { MQTTStatus_t status; - size_t packetSize; + uint32_t packetSize; /* Verify parameters. */ status = MQTT_GetPingreqPacketSize( NULL ); @@ -3434,7 +3440,7 @@ void test_MQTT_GetIncomingPacketTypeAndLength1( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_BadInputs( void ) { MQTTPublishInfo_t publishInfo = { 0 }; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3470,7 +3476,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_BadInputs( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_AllNULL( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3522,7 +3528,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_AllNULL( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_QoS1( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3554,7 +3560,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_QoS1( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_QoS2( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3586,7 +3592,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_QoS2( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_retain( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3618,7 +3624,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_retain( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_Duplicate( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3650,7 +3656,7 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_Duplicate( void ) void test_MQTT_SerializePublishHeaderWithoutTopic_VariousFlagsSetTopicLength( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 7 ]; MQTTStatus_t status = MQTTSuccess; size_t headerSize = 0; @@ -3685,12 +3691,12 @@ void test_MQTT_SerializePublishHeaderWithoutTopic_VariousFlagsSetTopicLength( vo void test_MQTT_SerializePublishHeader( void ) { MQTTPublishInfo_t publishInfo; - size_t remainingLength = 0; + uint32_t remainingLength = 0; uint8_t buffer[ 200 + 2 * BUFFER_PADDING_LENGTH ]; uint8_t expectedPacket[ 200 ]; uint8_t * pIterator; size_t bufferSize = sizeof( buffer ) - 2 * BUFFER_PADDING_LENGTH; - size_t packetSize = bufferSize; + uint32_t packetSize = bufferSize; MQTTStatus_t status = MQTTSuccess; MQTTFixedBuffer_t fixedBuffer = { .pBuffer = &buffer[ BUFFER_PADDING_LENGTH ], .size = bufferSize }; size_t headerSize = 0; @@ -4736,16 +4742,16 @@ void test_getProps( void ) pIndex = serializeutf_8( pIndex, MQTT_AUTH_METHOD_ID ); pIndex = serializeutf_8( pIndex, MQTT_AUTH_DATA_ID ); - uint32_t propCurrentIndex = 0U; + size_t propCurrentIndex = 0U; uint16_t topicAlias; uint8_t payloadFormat; const char * pResponseTopic; - uint16_t responseTopicLength; + size_t responseTopicLength; const char * correlationData; - uint16_t correlationLength; + size_t correlationLength; uint32_t messageExpiry; const char * pContentType; - uint16_t contentTypeLength; + size_t contentTypeLength; uint32_t subscriptionId; uint32_t sessionExpiry; uint16_t aliasMax; @@ -4754,20 +4760,20 @@ void test_getProps( void ) uint8_t retainAvailable; uint32_t maxPacketSize; const char * pClientId; - uint16_t clientIdLength; + size_t clientIdLength; uint8_t wildcard; uint8_t subAvailable; uint8_t propertyId; const char * pReasonString; - uint16_t reasonStringLength; + size_t reasonStringLength; uint8_t sharedSubAvailable; uint16_t serverKeepAlive; const char * pResponseInfo; - uint16_t responseInfoLength; + size_t responseInfoLength; const char * pAuthMethod; - uint16_t authMethodLength; + size_t authMethodLength; const char * pAuthData; - uint16_t authDataLength; + size_t authDataLength; MQTTUserProperty_t userProp; size_t counter = 0U; @@ -4996,9 +5002,9 @@ void test_getProps_decodeFailure( void ) uint32_t sessionExpiry; uint32_t maxPacketSize; const char * string; - uint16_t stringLength; + size_t stringLength; MQTTUserProperty_t userProp; - uint32_t propCurrentIndex = 0U; + size_t propCurrentIndex = 0U; uint8_t buffer[ 500 ] = { 0 }; size_t bufLength = 500; @@ -6447,7 +6453,7 @@ void test_getAckPacketSize_AllPacketTypes( void ) void test_MQTT_SkipNextProperty_NullPropertyBuilder( void ) { MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; status = MQTT_SkipNextProperty( NULL, ¤tIndex ); @@ -6478,7 +6484,7 @@ void test_MQTT_SkipNextProperty_NullBuffer( void ) { MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = NULL; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6500,7 +6506,7 @@ void test_MQTT_SkipNextProperty_IndexAtEnd( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6519,7 +6525,7 @@ void test_MQTT_SkipNextProperty_IndexBeyondEnd( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 10; + size_t currentIndex = 10; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6542,7 +6548,7 @@ void test_MQTT_SkipNextProperty_UnknownPropertyId( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6568,7 +6574,7 @@ void test_MQTT_SkipNextProperty_SessionExpiry( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6597,7 +6603,7 @@ void test_MQTT_SkipNextProperty_MaxPacketSize( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6625,7 +6631,7 @@ void test_MQTT_SkipNextProperty_WillDelay( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6653,7 +6659,7 @@ void test_MQTT_SkipNextProperty_MessageExpiry( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6681,7 +6687,7 @@ void test_MQTT_SkipNextProperty_Uint32_InsufficientBuffer( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6707,7 +6713,7 @@ void test_MQTT_SkipNextProperty_ReceiveMax( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6733,7 +6739,7 @@ void test_MQTT_SkipNextProperty_TopicAliasMax( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6759,7 +6765,7 @@ void test_MQTT_SkipNextProperty_TopicAlias( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6785,7 +6791,7 @@ void test_MQTT_SkipNextProperty_ServerKeepAlive( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6811,7 +6817,7 @@ void test_MQTT_SkipNextProperty_Uint16_InsufficientBuffer( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -6837,7 +6843,7 @@ void test_MQTT_SkipNextProperty_RequestResponse( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6862,7 +6868,7 @@ void test_MQTT_SkipNextProperty_RequestProblem( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6887,7 +6893,7 @@ void test_MQTT_SkipNextProperty_PayloadFormat( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6912,7 +6918,7 @@ void test_MQTT_SkipNextProperty_MaxQos( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6937,7 +6943,7 @@ void test_MQTT_SkipNextProperty_RetainAvailable( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6962,7 +6968,7 @@ void test_MQTT_SkipNextProperty_Wildcard( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -6987,7 +6993,7 @@ void test_MQTT_SkipNextProperty_SubAvailable( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7012,7 +7018,7 @@ void test_MQTT_SkipNextProperty_SharedSub( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7037,7 +7043,7 @@ void test_MQTT_SkipNextProperty_Uint8_InsufficientBuffer( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -7063,7 +7069,7 @@ void test_MQTT_SkipNextProperty_AuthMethod( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7088,7 +7094,7 @@ void test_MQTT_SkipNextProperty_ContentType( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7113,7 +7119,7 @@ void test_MQTT_SkipNextProperty_ResponseTopic( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7138,7 +7144,7 @@ void test_MQTT_SkipNextProperty_AssignedClientId( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7163,7 +7169,7 @@ void test_MQTT_SkipNextProperty_ReasonString( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7188,7 +7194,7 @@ void test_MQTT_SkipNextProperty_ResponseInfo( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7213,7 +7219,7 @@ void test_MQTT_SkipNextProperty_ServerRef( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7238,7 +7244,7 @@ void test_MQTT_SkipNextProperty_AuthData( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7263,7 +7269,7 @@ void test_MQTT_SkipNextProperty_CorrelationData( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7288,7 +7294,7 @@ void test_MQTT_SkipNextProperty_Utf8_InsufficientBufferForLength( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -7310,7 +7316,7 @@ void test_MQTT_SkipNextProperty_Utf8_InsufficientBufferForData( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7340,7 +7346,7 @@ void test_MQTT_SkipNextProperty_UserProperty( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7366,7 +7372,7 @@ void test_MQTT_SkipNextProperty_UserProperty_InsufficientBufferForKey( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -7391,7 +7397,7 @@ void test_MQTT_SkipNextProperty_UserProperty_InsufficientBufferForValue( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7422,7 +7428,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_OneByte( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7447,7 +7453,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_TwoBytes( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7473,7 +7479,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_FourBytes( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7498,7 +7504,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_InsufficientBuffer( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; propBuilder.pBuffer = testBuffer; propBuilder.bufferLength = MQTT_TEST_BUFFER_LENGTH; @@ -7521,7 +7527,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_InvalidEncoding( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7553,7 +7559,7 @@ void test_MQTT_SkipNextProperty_MultipleProperties( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7605,7 +7611,7 @@ void test_MQTT_SkipNextProperty_AtBufferBoundary( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7634,7 +7640,7 @@ void test_MQTT_SkipNextProperty_ZeroLengthString( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7660,7 +7666,7 @@ void test_MQTT_SkipNextProperty_UserProperty_ZeroLength( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7688,7 +7694,7 @@ void test_MQTT_SkipNextProperty_SubscriptionId_Zero( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7714,7 +7720,7 @@ void test_MQTT_SkipNextProperty_MaxUtf8Length( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; propBuilder.pBuffer = testBuffer; @@ -7742,7 +7748,7 @@ void test_MQTT_SkipNextProperty_AllPropertyTypes( void ) uint8_t testBuffer[ MQTT_TEST_BUFFER_LENGTH ]; MQTTPropBuilder_t propBuilder = { 0 }; MQTTStatus_t status; - uint32_t currentIndex = 0; + size_t currentIndex = 0; uint8_t * pIndex = testBuffer; uint32_t expectedIndex; diff --git a/test/unit-test/core_mqtt_utest.c b/test/unit-test/core_mqtt_utest.c index f8e37b915..5efbc6b0f 100644 --- a/test/unit-test/core_mqtt_utest.c +++ b/test/unit-test/core_mqtt_utest.c @@ -601,7 +601,7 @@ static MQTTStatus_t MQTT_SerializeAck_SuccessAndSetDisconnPending( const MQTTFix static uint8_t * MQTTV5_SerializeAckFixed_cb( uint8_t * pIndex, uint8_t packetType, uint16_t packetId, - size_t remainingLength, + uint32_t remainingLength, MQTTSuccessFailReasonCode_t reasonCode, int numcallbacks ) { @@ -663,7 +663,7 @@ MQTTStatus_t MQTT_SerializeAck_StubSuccess( const MQTTFixedBuffer_t * pFixedBuff static uint8_t * MQTTV5_SerializeDisconnectFixed_cb( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, int numcallbacks ) { ( void ) pIndex; @@ -730,8 +730,8 @@ static int32_t transportWritevSuccess( NetworkContext_t * pNetworkContext, } static MQTTStatus_t MQTT_GetDisconnectPacketSize_ExpectReasonMalformed( const MQTTPropBuilder_t * pDisconnectProperties, - size_t * pRemainingLength, - size_t * pPacketSize, + uint32_t * pRemainingLength, + uint32_t * pPacketSize, uint32_t maxPacketSize, MQTTSuccessFailReasonCode_t * pReasonCode, int numcallbacks ) @@ -750,7 +750,7 @@ static MQTTStatus_t MQTT_GetDisconnectPacketSize_ExpectReasonMalformed( const MQ static uint8_t * serializeDisconnectFixed_cb_OneByte( uint8_t * pIndex, MQTTSuccessFailReasonCode_t * pReasonCode, - size_t remainingLength, + uint32_t remainingLength, int numcallbacks ) { ( void ) pReasonCode; @@ -1515,7 +1515,7 @@ static void expectProcessLoopCalls( MQTTContext_t * const pContext, { MQTTStatus_t mqttStatus = MQTTSuccess; MQTTPacketInfo_t incomingPacket = { 0 }; - size_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; bool expectMoreCalls = true; /* Copy values passed in the parameter struct. */ MQTTStatus_t deserializeStatus = pExpectParams->deserializeStatus; @@ -4689,7 +4689,7 @@ void test_MQTT_Disconnect_already_disconnected( void ) MQTTStatus_t status; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t disconnectSize = 2; + uint32_t disconnectSize = 2; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -4782,7 +4782,7 @@ void test_MQTT_Disconnect2( void ) NetworkContext_t networkContext = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t disconnectSize = 2; + uint32_t disconnectSize = 2; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -4854,7 +4854,7 @@ void test_MQTT_Disconnect4( void ) NetworkContext_t networkContext = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t disconnectSize = 2; + uint32_t disconnectSize = 2; /* Fill the buffer with garbage data. */ memset( mqttBuffer, 0xAB, MQTT_TEST_BUFFER_LENGTH ); @@ -4908,7 +4908,7 @@ void test_MQTT_Disconnect4_status_disconnect_pending( void ) NetworkContext_t networkContext = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t disconnectSize = 2; + uint32_t disconnectSize = 2; /* Fill the buffer with garbage data. */ memset( mqttBuffer, 0xAB, MQTT_TEST_BUFFER_LENGTH ); @@ -5146,7 +5146,7 @@ void test_MQTT_ProcessLoop_HandleKeepAlive1( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTStatus_t mqttStatus; - size_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; setupTransportInterface( &transport ); transport.recv = transportRecvNoData; @@ -6538,7 +6538,7 @@ void test_MQTT_ProcessLoop_handleKeepAlive_Error_Paths3( void ) context.waitingForPingResp = false; /* Set expected return values in the loop. */ resetProcessLoopParams( &expectParams ); - size_t packetSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t packetSize = MQTT_PACKET_PINGREQ_SIZE; MQTT_GetPingreqPacketSize_ExpectAnyArgsAndReturn( MQTTSuccess ); MQTT_GetPingreqPacketSize_ReturnThruPtr_pPacketSize( &packetSize ); MQTT_SerializePingreq_ExpectAnyArgsAndReturn( MQTTSuccess ); @@ -6559,7 +6559,7 @@ void test_MQTT_ProcessLoop_handleKeepAlive_Error_Paths4( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; ProcessLoopReturns_t expectParams = { 0 }; - size_t packetSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t packetSize = MQTT_PACKET_PINGREQ_SIZE; setupTransportInterface( &transport ); transport.recv = transportRecvNoData; @@ -7668,7 +7668,7 @@ static void setupSubscriptionInfo( MQTTSubscribeInfo_t * pSubscribeInfo ) } -static uint8_t * MQTTV5_SerializeSubscribedHeader_cb( size_t remainingLength, +static uint8_t * MQTTV5_SerializeSubscribedHeader_cb( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId, int numcallbacks ) @@ -7681,7 +7681,7 @@ static uint8_t * MQTTV5_SerializeSubscribedHeader_cb( size_t remainingLength, return pIndex; } -static uint8_t * MQTT_SerializeSubscribedHeader_cb2( size_t remainingLength, +static uint8_t * MQTT_SerializeSubscribedHeader_cb2( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId, int numcallbacks ) @@ -7696,7 +7696,7 @@ static uint8_t * MQTT_SerializeSubscribedHeader_cb2( size_t remainingLength, return pIndex + SubscribeHeaderLength; } -static uint8_t * MQTT_SerializeUnsubscribedHeader_cb2( size_t remainingLength, +static uint8_t * MQTT_SerializeUnsubscribedHeader_cb2( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId, int numcallbacks ) @@ -7883,8 +7883,8 @@ void test_MQTTV5_Subscribe_happy_path( void ) MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; @@ -7953,8 +7953,8 @@ void test_MQTT_Subscribe_happy_path_not_connected( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; uint8_t ackPropsBuf[ 500 ]; @@ -8004,8 +8004,8 @@ void test_MQTTV5_Subscribe_happy_path1( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo[ 2 ]; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; @@ -8083,8 +8083,8 @@ void test_MQTTV5_Subscribe_happy_path2( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; uint8_t ackPropsBuf[ 500 ]; @@ -8131,8 +8131,8 @@ void test_MQTT_Subscribe_MultipleSubscriptions( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo[ 5 ]; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; @@ -8204,8 +8204,8 @@ void test_MQTTV5_Subscribe_happy_path3( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; @@ -8258,8 +8258,8 @@ void test_MQTT_Subscribe_error_paths1( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; /* Verify that an error is propagated when transport interface returns an error. */ setupNetworkBuffer( &networkBuffer ); @@ -8298,8 +8298,8 @@ void test_MQTT_Unsubscribe_error_paths1( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; /* Verify that an error is propagated when transport interface returns an error. */ setupNetworkBuffer( &networkBuffer ); @@ -8338,8 +8338,8 @@ void test_MQTT_Subscribe_error_paths_timerOverflowCheck( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; globalEntryTime = UINT32_MAX - 2U; @@ -8385,8 +8385,8 @@ void test_MQTT_Subscribe_error_paths_timerOverflowCheck1( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; globalEntryTime = UINT32_MAX - MQTT_SEND_TIMEOUT_MS + 1; @@ -8432,8 +8432,8 @@ void test_MQTT_Subscribe_error_paths2( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; /* Verify that an error is propagated when transport interface returns an error. */ setupNetworkBuffer( &networkBuffer ); @@ -8472,8 +8472,8 @@ void test_MQTT_Subscribe_error_paths_with_transport_failure( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; /* Verify that an error is propagated when transport interface returns an error. */ setupNetworkBuffer( &networkBuffer ); @@ -8509,8 +8509,8 @@ void test_MQTTV5_shared_subscriptions( void ) MQTTSubscribeInfo_t subscribeInfo = { 0 }; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; uint8_t ackPropsBuf[ 500 ]; size_t ackPropsBufLength = sizeof( ackPropsBuf ); @@ -8638,7 +8638,7 @@ void test_MQTT_Unsubscribe_invalid_params( void ) } -static uint8_t * MQTTV5_SerializeUnsubscribeHeader_cb( size_t remainingLength, +static uint8_t * MQTTV5_SerializeUnsubscribeHeader_cb( uint32_t remainingLength, uint8_t * pIndex, uint16_t packetId, int numcallbacks ) @@ -8662,8 +8662,8 @@ void test_MQTT_Unsubscribe_happy_path( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -8723,8 +8723,8 @@ void test_MQTT_Unsubscribe_MultipleSubscriptions( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo[ 5 ]; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; uint8_t buf[ 100 ]; @@ -8785,8 +8785,8 @@ void test_MQTT_Unsubscribe_happy_path_withUP( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -8816,8 +8816,8 @@ void test_MQTTV5_Unsubscribe_happy_path( void ) MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; MQTTPubAckInfo_t incomingRecords = { 0 }; MQTTPubAckInfo_t outgoingRecords = { 0 }; @@ -8874,8 +8874,8 @@ void test_MQTT_Unsubscribe_not_connected( void ) TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; MQTTSubscribeInfo_t subscribeInfo = { 0 }; - size_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; - size_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t remainingLength = MQTT_SAMPLE_REMAINING_LENGTH; + uint32_t packetSize = MQTT_SAMPLE_REMAINING_LENGTH; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -8930,7 +8930,7 @@ void test_MQTT_Ping_happy_path( void ) MQTTContext_t context = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -8962,7 +8962,7 @@ void test_MQTT_Ping_not_connected( void ) MQTTContext_t context = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); @@ -9004,7 +9004,7 @@ void test_MQTT_Ping_error_path( void ) MQTTContext_t context = { 0 }; TransportInterface_t transport = { 0 }; MQTTFixedBuffer_t networkBuffer = { 0 }; - size_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; + uint32_t pingreqSize = MQTT_PACKET_PINGREQ_SIZE; setupTransportInterface( &transport ); setupNetworkBuffer( &networkBuffer ); From bb62d81da404247ab4f71750266ec19550d0bcba Mon Sep 17 00:00:00 2001 From: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Thu, 29 Jan 2026 07:25:03 +0000 Subject: [PATCH 2/2] Update tests and add checks for size_t -> 32 bit conversion --- docs/doxygen/include/size_table.md | 14 +- source/core_mqtt.c | 26 +- source/core_mqtt_prop_serializer.c | 134 +++-- source/core_mqtt_serializer.c | 314 ++++++++--- source/core_mqtt_serializer_private.c | 5 + source/include/core_mqtt.h | 48 +- source/include/core_mqtt_serializer.h | 127 ++--- .../private/core_mqtt_serializer_private.h | 26 +- .../core_mqtt_prop_serializer_utest.c | 36 +- test/unit-test/core_mqtt_serializer_utest.c | 489 ++++++++++++------ 10 files changed, 843 insertions(+), 376 deletions(-) diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md index 6651d29a7..f8f10a090 100644 --- a/docs/doxygen/include/size_table.md +++ b/docs/doxygen/include/size_table.md @@ -9,7 +9,7 @@