Skip to content

Commit 389cd3e

Browse files
committed
pldm: check requester multipart size is valid
PLDM specification requires it to be power of two and minimum 256. Signed-off-by: Matt Johnston <[email protected]>
1 parent 2ea2dd1 commit 389cd3e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pldm/src/control/requester.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ pub async fn negotiate_transfer_parameters<'f>(
197197

198198
let req_types = req_types.iter().fold(0u64, |x, typ| x | 1 << typ);
199199

200+
if !part_size.is_power_of_two() || part_size < 256 {
201+
debug!("Bad part_size {}", part_size);
202+
return Err(PldmError::InvalidArgument);
203+
}
204+
200205
let req = control::NegotiateTransferParametersReq {
201206
part_size,
202207
protocols: req_types.to_le_bytes(),

0 commit comments

Comments
 (0)