Skip to content

Commit 0701f7f

Browse files
embedivermkj
authored andcommitted
I2C transport: Use only first 4 bytes of packet to decode header
The `MctpI2cHeader::decode(...)` method errors on slices that are not 4-byte. Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
1 parent 6fe0467 commit 0701f7f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mctp-estack/src/i2c.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ impl MctpI2cEncap {
104104
}
105105
}
106106

107-
let header = MctpI2cHeader::decode(packet)?;
107+
let header =
108+
MctpI2cHeader::decode(packet.get(..4).ok_or(Error::InvalidInput)?)?;
108109
// +1 for i2c source address field
109110
if header.byte_count != packet.len() + 1 {
110111
return Err(Error::InvalidInput);

0 commit comments

Comments
 (0)