dsp: base: Fix MultipartReceive Request decoding
This fix is based on DSP0240 v1.2.0 section 9.6.6 - Flag usage for
MultipartReceive (paragraph 351) and Table 17 MultipartReceive request
format.
- Removed RequestedSectionOffset check.
The Property can be 0 for any TransferOperation flag.
- Changed DataTransferHandle check.
The property can be 0 except with PLDM_XFER_NEXT_PART. Eg. In DSP0242
v1.0.0 section 9.8.2, Table 19, and DSP0240 v1.2.0 section 9.6.5, Table
17, when using MultipartReceive to read a file, the client has to send
transfer handle 0 with XFER_FIRST_PART.
Change-Id: I06428556f9dee341de97f72b015ed0347adc9454
Fixes: 9c76679224cf ("libpldm: Migrate to subproject")
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/dsp/base.c b/src/dsp/base.c
index cc805df..cd4878c 100644
--- a/src/dsp/base.c
+++ b/src/dsp/base.c
@@ -569,13 +569,14 @@
return PLDM_ERROR_UNEXPECTED_TRANSFER_FLAG_OPERATION;
}
- // A section offset of 0 is only valid on FIRST_PART or COMPLETE Xfers.
- if (*section_offset == 0 && (*transfer_opflag != PLDM_XFER_FIRST_PART &&
- *transfer_opflag != PLDM_XFER_COMPLETE)) {
- return PLDM_ERROR_INVALID_DATA;
- }
-
- if (*transfer_handle == 0 && *transfer_opflag != PLDM_XFER_COMPLETE) {
+ // By DSP0240 v1.2.0, section 9.6.5, Table 17, transfer handle can be 0 only
+ // if the transfer flag is one of XFER_FIRST_PART, XFER_COMPLETE or
+ // XFER_ABORT. In addition, it must be allowed in PLDM_XFER_CURRENT_PART as
+ // this may be used to retry the first part, in which case the transfer handle
+ // must again be 0. Therefore, the only operation for which it cannot be 0 is
+ // PLDM_XFER_NEXT_PART.
+ if ((*transfer_handle == 0) &&
+ (*transfer_opflag == PLDM_XFER_NEXT_PART)) {
return PLDM_ERROR_INVALID_DATA;
}