From ec7f20e8b634d4957258969ec82c7b3fe3802705 Mon Sep 17 00:00:00 2001 From: Peter Delevoryas Date: Fri, 13 May 2022 20:12:35 -0700 Subject: ncsi: Use response header for payload length In the Linux NC-SI driver[1], each response's length is validated with a statically declared payload length, _unless_ it's an OEM command or some more complicated NC-SI packet that you can't determine the length of just from the "type" field, in which case it just uses the length provided by the response's header. To support OEM response handlers without requiring too many modifications we can make the default payload length use the value specified in the handler table, and then allow OEM handlers to override the length by modifying the "length" in the response header within the handler implementation. [1] https://github.com/torvalds/linux/blob/ec7f49619d8ee13e108740c82f942cd401b989e9/net/ncsi/ncsi-rsp.c#L1215-L1220 Signed-off-by: Peter Delevoryas --- src/ncsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ncsi.c b/src/ncsi.c index bfe3088..d0632bb 100644 --- a/src/ncsi.c +++ b/src/ncsi.c @@ -195,7 +195,7 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) if (handler->handler) { handler->handler(slirp, nh, rnh); } - ncsi_rsp_len += handler->payload; + ncsi_rsp_len += ntohs(rnh->common.length); } else { rnh->common.length = 0; rnh->code = htons(NCSI_PKT_RSP_C_UNAVAILABLE); -- cgit v1.1