Skip to content

Commit

Permalink
[DiagnosticLogs] Allow TransferFileDesignator or size 0
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Feb 22, 2024
1 parent 8fbe0a7 commit aa8a37b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ CHIP_ERROR BDXDiagnosticLogsServerDelegate::OnTransferBegin(chip::bdx::BDXTransf
auto fileDesignator = transfer->GetFileDesignator();
LogFileDesignator("OnTransferBegin", fileDesignator);

VerifyOrReturnError(fileDesignator.size() != 0, CHIP_ERROR_UNKNOWN_RESOURCE_ID);

chip::CharSpan phaseErrorTarget(kErrorOnTransferBegin, sizeof(kErrorOnTransferBegin) - 1);
ReturnErrorOnFailure(CheckForErrorRequested(phaseErrorTarget, fileDesignator));

chip::CharSpan transferErrorTarget(kErrorTransferMethodNotSupported, sizeof(kErrorTransferMethodNotSupported) - 1);
VerifyOrReturnError(!transferErrorTarget.data_equal(fileDesignator), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
ReturnErrorOnFailure(CheckFileDesignatorAllowed(mFileDesignators, fileDesignator));

char outputFilePath[kMaxFilePathLen] = { 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ void DiagnosticLogsServer::HandleLogRequestForBdx(CommandHandler * commandObj, c
// INVALID_COMMAND.
VerifyOrReturn(transferFileDesignator.HasValue(), commandObj->AddStatus(path, Status::InvalidCommand));

VerifyOrReturn(transferFileDesignator.Value().size() > 0, commandObj->AddStatus(path, Status::ConstraintError));

VerifyOrReturn(transferFileDesignator.Value().size() <= kMaxFileDesignatorLen,
commandObj->AddStatus(path, Status::ConstraintError));

Expand Down
1 change: 0 additions & 1 deletion src/protocols/bdx/BdxTransferProxyDiagnosticLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ CHIP_ERROR BDXTransferProxyDiagnosticLog::Init(TransferSession * transferSession
uint16_t fileDesignatorLength = 0;
auto fileDesignator = transferSession->GetFileDesignator(fileDesignatorLength);

VerifyOrReturnError(fileDesignatorLength > 0, CHIP_ERROR_INVALID_STRING_LENGTH);
VerifyOrReturnError(fileDesignatorLength <= ArraySize(mFileDesignator), CHIP_ERROR_INVALID_STRING_LENGTH);

mTransfer = transferSession;
Expand Down
8 changes: 8 additions & 0 deletions src/protocols/bdx/StatusCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ StatusCode GetBdxStatusCodeFromChipError(CHIP_ERROR error)
{
status = StatusCode::kBadMessageContents;
}
else if (error == CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE)
{
status = StatusCode::kTransferMethodNotSupported;
}
else if (error == CHIP_ERROR_UNKNOWN_RESOURCE_ID)
{
status = StatusCode::kFileDesignatorUnknown;
}

return status;
}
Expand Down

0 comments on commit aa8a37b

Please sign in to comment.