sim_netdriver: some sim defconfig have problems when using the network

if the configured SIM_NETDEV_BUFSIZE < host MTU, there will be issues with access out of bounds

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-10-26 17:20:26 +08:00 committed by Xiang Xiao
parent 3a9c193bf7
commit 7c322c250a
1 changed files with 2 additions and 1 deletions

View File

@ -280,7 +280,8 @@ void sim_netdriver_setmacaddr(int devidx, unsigned char *macaddr)
void sim_netdriver_setmtu(int devidx, int mtu)
{
g_sim_dev[devidx].dev.netdev.d_pktsize = mtu + ETH_HDRLEN;
g_sim_dev[devidx].dev.netdev.d_pktsize = MIN(SIM_NETDEV_BUFSIZE,
mtu + ETH_HDRLEN);
}
void sim_netdriver_loop(void)