diff --git a/demos/src/aws_iot_demo_onboarding.c b/demos/src/aws_iot_demo_onboarding.c index dd67a88e3f..d1393b080e 100644 --- a/demos/src/aws_iot_demo_onboarding.c +++ b/demos/src/aws_iot_demo_onboarding.c @@ -93,7 +93,7 @@ /** * @brief Type for the context parameter for the #AwsIotOnboarding_DeviceCredentialsCallbackInfo_t callback. * It will be used for storing the received Certificate ID and the ownership token data received from the server through - * the callback, so that that can be used for provisioning the demo application. + * the callback, so that can be used for provisioning the demo application. */ typedef struct _demoDeviceCredentialsCallbackContext { @@ -496,9 +496,10 @@ int RunOnboardingDemo( bool awsIotMqttMode, IotLogError( "Request to get new credentials failed, error %s ", AwsIotOnboarding_strerror( requestStatus ) ); } - else if( newCertificateDataContext.pCertificateIdBuffer == NULL ) + else if( ( newCertificateDataContext.pCertificateIdBuffer == NULL ) || + ( newCertificateDataContext.pCertificateOwnershipToken == NULL ) ) { - IotLogInfo( "Don't have the Certificate ID to proceed for onboarding. So exiting...!" ); + IotLogInfo( "Don't have either the Certificate ID OR the Certificate Ownership Token (or both) to proceed with provisioning. So exiting...!" ); } else { diff --git a/libraries/aws/onboarding/src/aws_iot_onboarding_parser.c b/libraries/aws/onboarding/src/aws_iot_onboarding_parser.c index 20ef5b1c13..797ec0deef 100644 --- a/libraries/aws/onboarding/src/aws_iot_onboarding_parser.c +++ b/libraries/aws/onboarding/src/aws_iot_onboarding_parser.c @@ -455,15 +455,18 @@ AwsIotOnboardingError_t _AwsIotOnboarding_ParseOnboardDeviceResponse( AwsIotStat if( ( deviceConfigInnerKeyDecoder.type != IOT_SERIALIZER_SCALAR_TEXT_STRING ) || ( deviceConfigInnerValueDecoder.type != IOT_SERIALIZER_SCALAR_TEXT_STRING ) ) { - /** Opportunity for HYGENE! The serializer library allocates memory for the iterator. It can + /**The serializer library allocates memory for the iterator. It can * only be released by iterating to the last element in the map containers and "stepping out" of * the container * Thus, we will iterate to the end of the device configuration container to invalidate the * iterator. */ - while( ++configurationListIndex < numOfDeviceConfigurationEntries ) + size_t nextConfigEntryIndex = configurationListIndex + 1; + + while( nextConfigEntryIndex < numOfDeviceConfigurationEntries ) { _pAwsIotOnboardingDecoder->next( deviceConfigIter ); _pAwsIotOnboardingDecoder->next( deviceConfigIter ); + nextConfigEntryIndex++; } /* Advance to the "end" of the container. */ diff --git a/libraries/aws/onboarding/test/system/aws_iot_tests_onboarding_system.c b/libraries/aws/onboarding/test/system/aws_iot_tests_onboarding_system.c index 428796f2b6..505d97af7b 100644 --- a/libraries/aws/onboarding/test/system/aws_iot_tests_onboarding_system.c +++ b/libraries/aws/onboarding/test/system/aws_iot_tests_onboarding_system.c @@ -118,7 +118,7 @@ static const AwsIotOnboardingRequestParameterEntry_t _pTestParameters[] = /** * @brief Type for the context parameter for the #AwsIotOnboarding_DeviceCredentialsCallbackInfo_t callback. * It will be used for storing the received Certificate ID and the ownership token data received from the server through - * the callback, so that that can be used for provisioning the demo application. + * the callback, so that can be used for provisioning the demo application. */ typedef struct _deviceCredentialsCallbackContext {