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 <liqinhui@xiaomi.com>
This commit is contained in:
parent
89174e6a1a
commit
719191ac72
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue