]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OptionRomPkg/UndiRuntimeDxe/E100b.c
ShellPkg: Fix memory leak in 'ShellOpenFileByName'.
[mirror_edk2.git] / OptionRomPkg / UndiRuntimeDxe / E100b.c
index 6f953c319532cb40cad4d201ce696c669630c4d3..8b29c7ebbdf9df6216e2ddd435cdc6f47da93ebe 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides basic function upon network adapter card.\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -517,7 +517,8 @@ Configure (
   UINT8 my_filter;\r
 \r
   cmd_ptr   = GetFreeCB (AdapterInfo);\r
-  data_ptr  = (UINT8 *) (&cmd_ptr->PhysTBDArrayAddres);\r
+  ASSERT (cmd_ptr != NULL);\r
+  data_ptr  = (UINT8 *) cmd_ptr + sizeof (struct CB_Header);\r
 \r
   //\r
   // start the config data right after the command header\r
@@ -588,7 +589,8 @@ E100bSetupIAAddr (
   eaddrs    = (UINT16 *) AdapterInfo->CurrentNodeAddress;\r
 \r
   cmd_ptr   = GetFreeCB (AdapterInfo);\r
-  data_ptr  = (UINT16 *) (&cmd_ptr->PhysTBDArrayAddres);\r
+  ASSERT (cmd_ptr != NULL);\r
+  data_ptr  = (UINT16 *) ((UINT8 *) cmd_ptr +sizeof (struct CB_Header));\r
 \r
   //\r
   // AVOID a bug (?!) here by marking the command already completed.\r
@@ -1022,6 +1024,7 @@ E100bTransmit (
 \r
   tx_ptr_1  = (PXE_CPB_TRANSMIT *) (UINTN) cpb;\r
   tx_ptr_f  = (PXE_CPB_TRANSMIT_FRAGMENTS *) (UINTN) cpb;\r
+  Tmp_ptr = 0;\r
 \r
   //\r
   // stop reentrancy here\r
@@ -1387,7 +1390,7 @@ E100bReadEepromAndStationAddress (
   // in words\r
   //\r
   AdapterInfo->NVData_Len = eeprom_len = (UINT16) (1 << addr_len);\r
-  for (Index2 = 0, Index = 0; Index < eeprom_len; Index++) {\r
+  for (Index2 = 0, Index = 0; ((Index2 < PXE_MAC_LENGTH - 1) && (Index < eeprom_len)); Index++) {\r
     UINT16  value;\r
     value         = E100bReadEeprom (AdapterInfo, Index, addr_len);\r
     eedata[Index] = value;\r
@@ -1604,6 +1607,7 @@ CheckCBList (
       // check if Q is full\r
       //\r
       if (next (AdapterInfo->xmit_done_tail) != AdapterInfo->xmit_done_head) {\r
+        ASSERT (AdapterInfo->xmit_done_tail < TX_BUFFER_COUNT << 1);\r
         AdapterInfo->xmit_done[AdapterInfo->xmit_done_tail] = Tmp_ptr->free_data_ptr;\r
 \r
         UnMapIt (\r
@@ -2258,7 +2262,7 @@ E100bStatistics (
                   AdapterInfo->statistics->tx_lost_carrier;\r
 \r
   if (DBsize > sizeof db) {\r
-    DBsize = sizeof db;\r
+    DBsize = (UINT16) sizeof (db);\r
   }\r
 \r
   CopyMem ((VOID *) (UINTN) DBaddr, (VOID *) &db, (UINTN) DBsize);\r