]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/SnpDxe/Nvdata.c
Refine soma code to make code run safely.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Nvdata.c
index 9aa02e1a930ac313f9f075cf402c6ccb7f2b86a3..443979087e59c56ea87b7ae34df1c7d6a4b7c279 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
-               Implementation of reading and writing operations on the NVRAM device\r
-               attached to a network interface.\r
+       Implementation of reading and writing operations on the NVRAM device\r
+       attached to a network interface.\r
  \r
-Copyright (c) 2004 - 2007, Intel Corporation. <BR> \r
-All rights reserved. This program and the accompanying materials are licensed \r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed \r
 and made available under the terms and conditions of the BSD License which \r
 accompanies this distribution. The full text of the license may be found at \r
 http://opensource.org/licenses/bsd-license.php \r
@@ -48,7 +48,7 @@ PxeNvDataRead (
   Snp->Cdb.CPBsize    = PXE_CPBSIZE_NOT_USED;\r
   Snp->Cdb.CPBaddr    = PXE_CPBADDR_NOT_USED;\r
 \r
-  Snp->Cdb.DBsize     = sizeof (PXE_DB_NVDATA);\r
+  Snp->Cdb.DBsize     = (UINT16) sizeof (PXE_DB_NVDATA);\r
   Snp->Cdb.DBaddr     = (UINT64)(UINTN) Db;\r
 \r
   Snp->Cdb.StatCode   = PXE_STATCODE_INITIALIZE;\r
@@ -88,7 +88,9 @@ PxeNvDataRead (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  CopyMem (Buffer, Db->Data.Byte + Offset, BufferSize);\r
+  ASSERT (Offset < sizeof (Db->Data));\r
+\r
+  CopyMem (Buffer, &Db->Data.Byte[Offset], BufferSize);\r
 \r
   return EFI_SUCCESS;\r
 }\r