@@ -152,10 +152,32 @@ void DefaultOTARequestor::OnQueryImageResponse(void * context, const QueryImageR
152
152
153
153
if (err != CHIP_NO_ERROR)
154
154
{
155
+ ChipLogError (SoftwareUpdate, " QueryImageResponse contains invalid fields: %" CHIP_ERROR_FORMAT, err.Format ());
155
156
requestorCore->RecordErrorUpdateState (UpdateFailureState::kQuerying , err);
156
157
return ;
157
158
}
158
159
160
+ // This should never happen since receiving a response implies that a CASE session had previously been established with a
161
+ // valid provider
162
+ if (!requestorCore->mProviderLocation .HasValue ())
163
+ {
164
+ ChipLogError (SoftwareUpdate, " No provider location set" );
165
+ requestorCore->RecordErrorUpdateState (UpdateFailureState::kQuerying , CHIP_ERROR_INCORRECT_STATE);
166
+ return ;
167
+ }
168
+
169
+ // The Operational Node ID in the host field SHALL match the NodeID of the OTA Provider responding with the
170
+ // QueryImageResponse
171
+ if (update.nodeId != requestorCore->mProviderLocation .Value ().providerNodeID )
172
+ {
173
+ ChipLogError (SoftwareUpdate,
174
+ " The ImageURI provider node 0x" ChipLogFormatX64
175
+ " does not match the QueryImageResponse provider node 0x" ChipLogFormatX64,
176
+ ChipLogValueX64 (update.nodeId ), ChipLogValueX64 (requestorCore->mProviderLocation .Value ().providerNodeID ));
177
+ requestorCore->RecordErrorUpdateState (UpdateFailureState::kQuerying , CHIP_ERROR_WRONG_NODE_ID);
178
+ return ;
179
+ }
180
+
159
181
if (update.softwareVersion > requestorCore->mCurrentVersion )
160
182
{
161
183
ChipLogDetail (SoftwareUpdate, " Update available from version %" PRIu32 " to %" PRIu32, requestorCore->mCurrentVersion ,
0 commit comments