Skip to content

Commit d854a29

Browse files
committed
mctp-estack: Check control listener message types
Catches if an incorrectly bound listener is passed. Signed-off-by: Matt Johnston <[email protected]>
1 parent 38539af commit d854a29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mctp-estack/src/control.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,14 @@ pub fn mctp_control_rx_req<'f, 'l, L>(
230230
where
231231
L: Listener,
232232
{
233-
let (buf, ch, _typ, ic) = listener.recv(buf)?;
233+
let (buf, ch, typ, ic) = listener.recv(buf)?;
234234
if ic.0 {
235235
return Err(Error::InvalidInput);
236236
}
237+
if typ != mctp::MCTP_TYPE_CONTROL {
238+
// Listener was bound to the wrong type?
239+
return Err(Error::BadArgument);
240+
}
237241

238242
let msg = MctpControlMsg::from_buf(buf).map_err(|_| Error::InvalidInput)?;
239243
Ok((ch, msg))

0 commit comments

Comments
 (0)