netlib_getarptab: fix codechecker high level issue

197:  paysize = RTA_PAYLOAD(&resp->attr);
198:  if (paysize > maxsize)
199:    {
200:      paysize = maxsize;
201:    }
202:
203:  memcpy(arptab, resp->data, paysize);

Memory copy function accesses out-of-bound array element

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-10-12 17:28:56 +08:00 committed by Xiang Xiao
parent 6fb173e3d5
commit cfb64cffb1

View File

@ -99,7 +99,7 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab,
/* Pre-allocate a buffer to hold the response */
maxsize = CONFIG_NET_ARPTAB_SIZE * sizeof(struct arp_entry_s);
maxsize = nentries * sizeof(struct arp_entry_s);
allocsize = SIZEOF_NETLIB_RECVFROM_RESPONSE_S(maxsize);
resp = (FAR struct netlib_recvfrom_response_s *)malloc(allocsize);
if (resp == NULL)