From 719191ac7265ac0ff9224e1fc970ce624c6f2153 Mon Sep 17 00:00:00 2001 From: liqinhui Date: Mon, 7 Aug 2023 17:03:31 +0800 Subject: [PATCH] net/local: Return an error when write the too big packet. Verification: Write a packet, the length is bigger than CONFIG_DEV_FIFO_SIZE. The return value should be -1, and the errno is EMSGSIZE. Signed-off-by: liqinhui --- net/local/local_sendpacket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c index 1c75d3c24ab..f941dc0de08 100644 --- a/net/local/local_sendpacket.c +++ b/net/local/local_sendpacket.c @@ -130,6 +130,12 @@ int local_send_packet(FAR struct file *filep, FAR const struct iovec *buf, len16 += iov->iov_len; } + if (len16 > CONFIG_DEV_FIFO_SIZE - sizeof(uint16_t)) + { + nerr("ERROR: Packet is too big: %d\n", len16); + return -EMSGSIZE; + } + ret = local_fifo_write(filep, (FAR const uint8_t *)&len16, sizeof(uint16_t)); if (ret != sizeof(uint16_t))