Revision: 16655
          http://sourceforge.net/p/edk2/code/16655
Author:   oliviermartin
Date:     2015-01-23 16:09:07 +0000 (Fri, 23 Jan 2015)
Log Message:
-----------
ArmPkg/NorFlashDxe : Fix the check of flash addresses

Fix the check to prevent any reading past the end of the nor flash.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <[email protected]>
Reviewed-by: Olivier Martin <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

Modified: trunk/edk2/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
===================================================================
--- trunk/edk2/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c 2015-01-23 
16:07:38 UTC (rev 16654)
+++ trunk/edk2/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c 2015-01-23 
16:09:07 UTC (rev 16655)
@@ -805,8 +805,7 @@
   OUT VOID                *Buffer
   )
 {
-  UINT32              NumBlocks;
-  UINTN               StartAddress;
+  UINTN  StartAddress;
 
   // The buffer must be valid
   if (Buffer == NULL) {
@@ -818,15 +817,7 @@
     return EFI_SUCCESS;
   }
 
-  // All blocks must be within the device
-  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
-
-  if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
-    DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed last 
block\n"));
-    return EFI_INVALID_PARAMETER;
-  }
-
-  if (Offset + BufferSizeInBytes >= Instance->Size) {
+  if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > 
Instance->Size) {
     DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed device 
size.\n"));
     return EFI_INVALID_PARAMETER;
   }


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to