astlpc: Add check for MCTP hdr version
The only valid version number at this stage is 1.
Change-Id: I2dc82e272047184f62c202e4e0643057290499cd
Signed-off-by: Rashmica Gupta <rashmica@linux.ibm.com>
diff --git a/astlpc.c b/astlpc.c
index 455276d..df4e245 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -976,6 +976,7 @@
static void mctp_astlpc_rx_start(struct mctp_binding_astlpc *astlpc)
{
struct mctp_pktbuf *pkt;
+ struct mctp_hdr *hdr;
uint32_t body, packet;
mctp_astlpc_lpc_read(astlpc, &body, astlpc->layout.rx.offset,
@@ -1016,6 +1017,13 @@
if (!mctp_astlpc_kcs_send(astlpc, 0x2))
astlpc->layout.rx.state = buffer_state_released;
+ hdr = mctp_pktbuf_hdr(pkt);
+ if (hdr->ver != 1) {
+ mctp_pktbuf_free(pkt);
+ astlpc_prdebug(astlpc, "Dropped packet with invalid version");
+ return;
+ }
+
/*
* v3 will validate the CRC32 in the medium-specific trailer and adjust
* the packet size accordingly. On older protocols validation is a no-op