From 1966704631d800ad67d3b5d9a807f8ac64b9be68 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sat, 25 Mar 2023 01:12:12 -0400 Subject: [PATCH] Stop getting a subject descriptor from a gone-async command in Darwin OTA. (#25829) Also grab our local node id before something has a chance to kill our exchange or its session. --- src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm index 1824bbb44b49c1..d85222411918fe 100644 --- a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm @@ -610,6 +610,9 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath return; } + auto fabricIndex = commandObj->GetAccessingFabricIndex(); + auto ourNodeId = commandObj->GetExchangeContext()->GetSessionHandle()->AsSecureSession()->GetLocalScopedNodeId(); + auto * commandParams = [[MTROTASoftwareUpdateProviderClusterQueryImageParams alloc] init]; CHIP_ERROR err = ConvertToQueryImageParams(commandData, commandParams); if (err != CHIP_NO_ERROR) { @@ -666,8 +669,6 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath } // If there is an update available, try to prepare for a transfer. - auto fabricIndex = handler->GetSubjectDescriptor().fabricIndex; - auto nodeId = handler->GetSubjectDescriptor().subject; CHIP_ERROR err = gOtaSender.PrepareForTransfer(fabricIndex, nodeId); if (CHIP_NO_ERROR != err) { @@ -694,11 +695,10 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath gOtaSender.ResetState(); return; } - auto targetNodeId = handler->GetExchangeContext()->GetSessionHandle()->AsSecureSession()->GetLocalScopedNodeId(); char uriBuffer[kMaxBDXURILen]; MutableCharSpan uri(uriBuffer); - err = bdx::MakeURI(targetNodeId.GetNodeId(), AsCharSpan(data.imageURI), uri); + err = bdx::MakeURI(ourNodeId.GetNodeId(), AsCharSpan(data.imageURI), uri); if (CHIP_NO_ERROR != err) { LogErrorOnFailure(err); handler->AddStatus(cachedCommandPath, StatusIB(err).mStatus);