qemu/edk2/fde052fbd89c35617e14f628ca96e2d9ceff6c6f
NetworkPkg/ArpDxe: Fix Coverity null-deref and integer overflow
Two Coverity-reported defects in ArpImpl.c:
1. ArpSendFrame: When AllocatePool returns NULL, the existing code logs
an error and asserts, but then falls through and dereferences the NULL
Packet pointer into TmpPtr. In release builds where ASSERT is a no-op
this causes a null-dereference. Add 'goto CLEAN_EXIT' to exit cleanly.
2. ArpFindCacheEntry: AllocatePool is called with 'FoundCount *
FoundEntryLength' where both operands are UINT32, so the
multiplication is done in 32 bits and can overflow before the result
is widened to UINTN. The root cause is that the UINTN value returned
by NetMapGetCount() is silently truncated to UINT32 when stored in
FoundCount.
Declare FoundCount as UINTN and drop the truncating cast on the
NetMapGetCount() return value, so the multiplication is performed at
pointer width. Since the EntryCount output parameter is a UINT32,
return EFI_OUT_OF_RESOURCES if FoundCount does not fit in 32 bits
instead of silently truncating it, and make the narrowing assignment
to *EntryCount explicit.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Cc: Mike Beaton <mjsbeaton@gmail.com>
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
1 file changed