mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/Lan9118Dxe: Fix risk of buffer overflow.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Ronald Cron <ronald.cron@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17107 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ac8f1e103d
commit
f22e965895
|
@ -1412,12 +1412,6 @@ SnpReceive (
|
|||
PLength = GET_RXSTATUS_PACKET_LENGTH(RxFifoStatus);
|
||||
LanDriver->Stats.RxTotalBytes += (PLength - 4);
|
||||
|
||||
// Check buffer size
|
||||
if (*BuffSize < PLength) {
|
||||
*BuffSize = PLength;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
// If padding is applied, read more DWORDs
|
||||
if (PLength % 4) {
|
||||
Padding = 4 - (PLength % 4);
|
||||
|
@ -1427,6 +1421,12 @@ SnpReceive (
|
|||
Padding = 0;
|
||||
}
|
||||
|
||||
// Check buffer size
|
||||
if (*BuffSize < (PLength + Padding)) {
|
||||
*BuffSize = PLength + Padding;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
// Set the amount of data to be transfered out of FIFO for THIS packet
|
||||
// This can be used to trigger an interrupt, and status can be checked
|
||||
RxCfgValue = MmioRead32 (LAN9118_RX_CFG);
|
||||
|
|
Loading…
Reference in New Issue