refine the code and add more security check.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9691 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2010-01-08 02:35:56 +00:00
parent 33338afebd
commit e285199897
18 changed files with 499 additions and 493 deletions

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of driver entry point and driver binding protocol.
Copyright (c) 2004 - 2009, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials are licensed
and made available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
Copyright (c) 2004 - 2010, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials are licensed
and made available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -49,13 +49,13 @@ SnpNotifyExitBootServices (
/**
Send command to UNDI. It does nothing currently.
@param Cdb command to be sent to UNDI.
@retval EFI_INVALID_PARAMETER The command is 0.
@retval EFI_UNSUPPORTED Default return status because it's not
@retval EFI_INVALID_PARAMETER The command is 0.
@retval EFI_UNSUPPORTED Default return status because it's not
supported currently.
**/
EFI_STATUS
IssueHwUndiCommand (
@@ -81,7 +81,7 @@ IssueHwUndiCommand (
@param Buffer Pointer to buffer.
@param Length Length of buffer in bytes.
@return 8-bit checksum of all bytes in buffer, or zero if ptr is NULL or len
@return 8-bit checksum of all bytes in buffer, or zero if ptr is NULL or len
is zero.
**/
@@ -178,7 +178,7 @@ SimpleNetworkDriverSupported (
//
// Check to see if !PXE structure is valid. Paragraph alignment of !PXE structure is required.
//
if (NiiProtocol->Id & 0x0F) {
if ((NiiProtocol->Id & 0x0F) != 0) {
DEBUG ((EFI_D_NET, "\n!PXE structure is not paragraph aligned.\n"));
Status = EFI_UNSUPPORTED;
goto Done;
@@ -615,7 +615,7 @@ SimpleNetworkDriverStart (
}
if (Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) {
if ((Pxe->hw.Implementation & PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED) != 0) {
Snp->Mode.ReceiveFilterMask |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
}
@@ -725,7 +725,7 @@ NiiError:
restrictions for this service. DisconnectController()
must follow these calling restrictions. If any other agent wishes
to call Stop() it must also follow these calling restrictions.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of

View File

@@ -1,11 +1,11 @@
/** @file
Implementation of collecting the statistics on a network interface.
Copyright (c) 2004 - 2007, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials are licensed
and made available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
Copyright (c) 2004 - 2010, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials are licensed
and made available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@@ -18,15 +18,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Resets or collects the statistics on a network interface.
This function resets or collects the statistics on a network interface. If the
size of the statistics table specified by StatisticsSize is not big enough for
all the statistics that are collected by the network interface, then a partial
buffer of statistics is returned in StatisticsTable, StatisticsSize is set to
the size required to collect all the available statistics, and
buffer of statistics is returned in StatisticsTable, StatisticsSize is set to
the size required to collect all the available statistics, and
EFI_BUFFER_TOO_SMALL is returned.
If StatisticsSize is big enough for all the statistics, then StatisticsTable
will be filled, StatisticsSize will be set to the size of the returned
If StatisticsSize is big enough for all the statistics, then StatisticsTable
will be filled, StatisticsSize will be set to the size of the returned
StatisticsTable structure, and EFI_SUCCESS is returned.
If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.
If Reset is FALSE, and both StatisticsSize and StatisticsTable are NULL, then
@@ -36,30 +36,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
@param Reset Set to TRUE to reset the statistics for the network interface.
@param StatisticsSize On input the size, in bytes, of StatisticsTable. On output
@param StatisticsSize On input the size, in bytes, of StatisticsTable. On output
the size, in bytes, of the resulting table of statistics.
@param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
contains the statistics. Type EFI_NETWORK_STATISTICS is
defined in "Related Definitions" below.
@param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
contains the statistics. Type EFI_NETWORK_STATISTICS is
defined in "Related Definitions" below.
@retval EFI_SUCCESS The requested operation succeeded.
@retval EFI_NOT_STARTED The Simple Network Protocol interface has not been
started by calling Start().
@retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is
NULL. The current buffer size that is needed to
@retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is
NULL. The current buffer size that is needed to
hold all the statistics is returned in StatisticsSize.
@retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is
@retval EFI_BUFFER_TOO_SMALL StatisticsSize is not NULL and StatisticsTable is
not NULL. The current buffer size that is needed
to hold all the statistics is returned in
StatisticsSize. A partial set of statistics is
to hold all the statistics is returned in
StatisticsSize. A partial set of statistics is
returned in StatisticsTable.
@retval EFI_INVALID_PARAMETER StatisticsSize is NULL and StatisticsTable is not
@retval EFI_INVALID_PARAMETER StatisticsSize is NULL and StatisticsTable is not
NULL.
@retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not
@retval EFI_DEVICE_ERROR The Simple Network Protocol interface has not
been initialized by calling Initialize().
@retval EFI_DEVICE_ERROR An error was encountered collecting statistics
@retval EFI_DEVICE_ERROR An error was encountered collecting statistics
from the NIC.
@retval EFI_UNSUPPORTED The NIC does not support collecting statistics
@retval EFI_UNSUPPORTED The NIC does not support collecting statistics
from the network interface.
**/
@@ -197,7 +197,7 @@ SnpUndi32Statistics (
break;
}
if (Db->Supported & Mask) {
if ((Db->Supported & Mask) != 0) {
*Stp = Db->Data[Index];
Size = Index + 1;
} else {
@@ -208,7 +208,7 @@ SnpUndi32Statistics (
// Compute size up to last supported statistic.
//
while (++Index < 64) {
if (Db->Supported & (Mask = LShiftU64 (Mask, 1))) {
if ((Db->Supported & (Mask = LShiftU64 (Mask, 1))) != 0) {
Size = Index;
}
}