From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 71FE2222A54C7 for ; Tue, 2 Jan 2018 21:58:21 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2018 22:03:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,500,1508828400"; d="scan'208";a="191818368" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 02 Jan 2018 22:03:23 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 22:03:23 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 22:03:22 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Wed, 3 Jan 2018 14:03:20 +0800 From: "Wu, Jiaxin" To: "Wang, Fan" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Ye, Ting" Thread-Topic: [Patch 2/3] MdeModulePkg/DxeNetLib: Add parameter check and ASSERT handling. Thread-Index: AQHThDsTtA49jwyFM0ahEEb5nmqiGaNhqJ4A Date: Wed, 3 Jan 2018 06:03:19 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416358D9F@SHSMSX103.ccr.corp.intel.com> References: <1514946711-4056-1-git-send-email-fan.wang@intel.com> <1514946711-4056-3-git-send-email-fan.wang@intel.com> In-Reply-To: <1514946711-4056-3-git-send-email-fan.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGI3NjExYTctZDQ4ZS00MjM2LTg3MDUtMjJlMzZkODI1ZDgwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlZOdnVYdVY3XC9Ha1JkWmROQWF6aEQrVGpmeVpWY1hudHZST1VHaHA5WDJ3PSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 2/3] MdeModulePkg/DxeNetLib: Add parameter check and ASSERT handling. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jan 2018 05:58:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiaxin Wu > -----Original Message----- > From: Wang, Fan > Sent: Wednesday, January 3, 2018 10:32 AM > To: edk2-devel@lists.01.org > Cc: Wang, Fan ; Fu, Siyuan ; Ye, > Ting ; Wu, Jiaxin > Subject: [Patch 2/3] MdeModulePkg/DxeNetLib: Add parameter check and > ASSERT handling. >=20 > From: Wang Fan >=20 > * Library API should check the input parameters before use, or > ASSERT to tell it has to meet some requirements. But in DxeNetLib, > not all functions follows this rule. > * ASSERT shouldn't be used as error handling, add some handling code > for errors. > * Add some ASSERT commence in function notes. >=20 > Cc: Fu Siyuan > Cc: Ye Ting > Cc: Jiaxin Wu > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 119 > +++++++++++++++++++++++++---- > 1 file changed, 105 insertions(+), 14 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index 0f00f79..90f17b7 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -1,9 +1,9 @@ > /** @file > Network library. >=20 > -Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
> (C) Copyright 2015 Hewlett Packard Enterprise Development LP
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at > http://opensource.org/licenses/bsd-license.php > @@ -196,10 +196,11 @@ SyslogLocateSnp ( > Transmit a syslog packet synchronously through SNP. The Packet > already has the ethernet header prepended. This function should > fill in the source MAC because it will try to locate a SNP each > time it is called to avoid the problem if SNP is unloaded. > This code snip is copied from MNP. > + If Packet is NULL, then ASSERT(). >=20 > @param[in] Packet The Syslog packet > @param[in] Length The length of the packet >=20 > @retval EFI_DEVICE_ERROR Failed to locate a usable SNP protocol > @@ -217,10 +218,12 @@ SyslogSendPacket ( > ETHER_HEAD *Ether; > EFI_STATUS Status; > EFI_EVENT TimeoutEvent; > UINT8 *TxBuf; >=20 > + ASSERT (Packet !=3D NULL); > + > Snp =3D SyslogLocateSnp (); >=20 > if (Snp =3D=3D NULL) { > return EFI_DEVICE_ERROR; > } > @@ -308,11 +311,11 @@ ON_EXIT: > @param[in] Line The line of code in the File that contains the c= urrent log > @param[in] Message The log message > @param[in] BufLen The lenght of the Buf > @param[out] Buf The buffer to put the packet data >=20 > - @return The length of the syslog packet built. > + @return The length of the syslog packet built, 0 represents no packet = is > built. >=20 > **/ > UINT32 > SyslogBuildPacket ( > IN UINT32 Level, > @@ -322,10 +325,11 @@ SyslogBuildPacket ( > IN UINT8 *Message, > IN UINT32 BufLen, > OUT CHAR8 *Buf > ) > { > + EFI_STATUS Status; > ETHER_HEAD *Ether; > IP4_HEAD *Ip4; > EFI_UDP_HEADER *Udp4; > EFI_TIME Time; > UINT32 Pri; > @@ -377,12 +381,14 @@ SyslogBuildPacket ( >=20 > // > // Build the syslog message body with Timestamp machine module > Message > // > Pri =3D ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7); > - gRT->GetTime (&Time, NULL); > - ASSERT ((Time.Month <=3D 12) && (Time.Month >=3D 1)); > + Status =3D gRT->GetTime (&Time, NULL); > + if (EFI_ERROR (Status)) { > + return 0; > + } >=20 > // > // Use %a to format the ASCII strings, %s to format UNICODE strings > // > Len =3D 0; > @@ -437,10 +443,12 @@ SyslogBuildPacket ( > __FILE__, > __LINE__, > NetDebugASPrint ("State transit to %a\n", Name) > ) >=20 > + If Format is NULL, then ASSERT(). > + > @param Format The ASCII format string. > @param ... The variable length parameter whose format is determine= d > by the Format string. >=20 > @return The buffer containing the formatted message, > @@ -455,10 +463,12 @@ NetDebugASPrint ( > ) > { > VA_LIST Marker; > CHAR8 *Buf; >=20 > + ASSERT (Format !=3D NULL); > + > Buf =3D (CHAR8 *) AllocatePool (NET_DEBUG_MSG_LEN); >=20 > if (Buf =3D=3D NULL) { > return NULL; > } > @@ -481,11 +491,12 @@ NetDebugASPrint ( > @param File The file that contains the log. > @param Line The exact line that contains the log. > @param Message The user message to log. >=20 > @retval EFI_INVALID_PARAMETER Any input parameter is invalid. > - @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the > packet > + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the > packet. > + @retval EFI_DEVICE_ERROR Device error occurs. > @retval EFI_SUCCESS The log is discard because that it is mo= re verbose > than the mNetDebugLevelMax. Or, it has b= een sent out. > **/ > EFI_STATUS > EFIAPI > @@ -502,11 +513,11 @@ NetDebugOutput ( > EFI_STATUS Status; >=20 > // > // Check whether the message should be sent out > // > - if (Message =3D=3D NULL) { > + if (Message =3D=3D NULL || File =3D=3D NULL || Module =3D=3D NULL) { > return EFI_INVALID_PARAMETER; > } >=20 > if (Level > mNetDebugLevelMax) { > Status =3D EFI_SUCCESS; > @@ -535,13 +546,17 @@ NetDebugOutput ( > Line, > Message, > NET_SYSLOG_PACKET_LEN, > Packet > ); > + if (Len =3D=3D 0) { > + Status =3D EFI_DEVICE_ERROR; > + } else { > + mSyslogPacketSeq++; > + Status =3D SyslogSendPacket (Packet, Len); > + } >=20 > - mSyslogPacketSeq++; > - Status =3D SyslogSendPacket (Packet, Len); > FreePool (Packet); >=20 > ON_EXIT: > FreePool (Message); > return Status; > @@ -673,10 +688,12 @@ NetIp4IsUnicast ( > } >=20 > /** > Check whether the incoming IPv6 address is a valid unicast address. >=20 > + ASSERT if Ip6 is NULL. > + > If the address is a multicast address has binary 0xFF at the start, it= is not > a valid unicast address. If the address is unspecified ::, it is not a= valid > unicast address to be assigned to any node. If the address is loopback > address > ::1, it is also not a valid unicast address to be assigned to any phys= ical > interface. > @@ -693,10 +710,12 @@ NetIp6IsValidUnicast ( > ) > { > UINT8 Byte; > UINT8 Index; >=20 > + ASSERT (Ip6 !=3D NULL); > + > if (Ip6->Addr[0] =3D=3D 0xFF) { > return FALSE; > } >=20 > for (Index =3D 0; Index < 15; Index++) { > @@ -715,10 +734,12 @@ NetIp6IsValidUnicast ( > } >=20 > /** > Check whether the incoming Ipv6 address is the unspecified address or = not. >=20 > + ASSERT if Ip6 is NULL. > + > @param[in] Ip6 - Ip6 address, in network order. >=20 > @retval TRUE - Yes, unspecified > @retval FALSE - No >=20 > @@ -729,10 +750,12 @@ NetIp6IsUnspecifiedAddr ( > IN EFI_IPv6_ADDRESS *Ip6 > ) > { > UINT8 Index; >=20 > + ASSERT (Ip6 !=3D NULL); > + > for (Index =3D 0; Index < 16; Index++) { > if (Ip6->Addr[Index] !=3D 0) { > return FALSE; > } > } > @@ -741,10 +764,12 @@ NetIp6IsUnspecifiedAddr ( > } >=20 > /** > Check whether the incoming Ipv6 address is a link-local address. >=20 > + ASSERT if Ip6 is NULL. > + > @param[in] Ip6 - Ip6 address, in network order. >=20 > @retval TRUE - Yes, link-local address > @retval FALSE - No >=20 > @@ -777,10 +802,13 @@ NetIp6IsLinkLocalAddr ( > } >=20 > /** > Check whether the Ipv6 address1 and address2 are on the connected > network. >=20 > + ASSERT if Ip1 or Ip2 is NULL. > + ASSERT if PrefixLength exceeds IP6_PREFIX_MAX. > + > @param[in] Ip1 - Ip6 address1, in network order. > @param[in] Ip2 - Ip6 address2, in network order. > @param[in] PrefixLength - The prefix length of the checking net. >=20 > @retval TRUE - Yes, connected. > @@ -813,11 +841,10 @@ NetIp6IsNetEqual ( > } >=20 > if (Bit > 0) { > Mask =3D (UINT8) (0xFF << (8 - Bit)); >=20 > - ASSERT (Byte < 16); > if ((Ip1->Addr[Byte] & Mask) !=3D (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } >=20 > @@ -826,10 +853,12 @@ NetIp6IsNetEqual ( >=20 >=20 > /** > Switches the endianess of an IPv6 address >=20 > + ASSERT if Ip6 is NULL. > + > This function swaps the bytes in a 128-bit IPv6 address to switch the = value > from little endian to big endian or vice versa. The byte swapped value= is > returned. >=20 > @param Ip6 Points to an IPv6 address > @@ -844,10 +873,12 @@ Ip6Swap128 ( > ) > { > UINT64 High; > UINT64 Low; >=20 > + ASSERT (Ip6 !=3D NULL); > + > CopyMem (&High, Ip6, sizeof (UINT64)); > CopyMem (&Low, &Ip6->Addr[8], sizeof (UINT64)); >=20 > High =3D SwapBytes64 (High); > Low =3D SwapBytes64 (Low); > @@ -891,10 +922,12 @@ NetRandomInitSeed ( >=20 >=20 > /** > Extract a UINT32 from a byte stream. >=20 > + ASSERT if Buf is NULL. > + > Copy a UINT32 from a byte stream, then converts it from Network > byte order to host byte order. Use this function to avoid alignment er= ror. >=20 > @param[in] Buf The buffer to extract the UINT32. >=20 > @@ -907,18 +940,22 @@ NetGetUint32 ( > IN UINT8 *Buf > ) > { > UINT32 Value; >=20 > + ASSERT (Buf !=3D NULL); > + > CopyMem (&Value, Buf, sizeof (UINT32)); > return NTOHL (Value); > } >=20 >=20 > /** > Put a UINT32 to the byte stream in network byte order. >=20 > + ASSERT if Buf is NULL. > + > Converts a UINT32 from host byte order to network byte order. Then cop= y > it to the > byte stream. >=20 > @param[in, out] Buf The buffer to put the UINT32. > @param[in] Data The data to be converted and put into th= e byte > stream. > @@ -929,10 +966,12 @@ EFIAPI > NetPutUint32 ( > IN OUT UINT8 *Buf, > IN UINT32 Data > ) > { > + ASSERT (Buf !=3D NULL); > + > Data =3D HTONL (Data); > CopyMem (Buf, &Data, sizeof (UINT32)); > } >=20 >=20 > @@ -1027,10 +1066,12 @@ NetListRemoveTail ( >=20 >=20 > /** > Insert a new node entry after a designated node entry of a doubly link= ed > list. >=20 > + ASSERT if PrevEntry or NewEntry is NULL. > + > Inserts a new node entry donated by NewEntry after the node entry > donated by PrevEntry > of the doubly linked list. >=20 > @param[in, out] PrevEntry The previous entry to insert af= ter. > @param[in, out] NewEntry The new entry to insert. > @@ -1041,20 +1082,24 @@ EFIAPI > NetListInsertAfter ( > IN OUT LIST_ENTRY *PrevEntry, > IN OUT LIST_ENTRY *NewEntry > ) > { > + ASSERT (PrevEntry !=3D NULL && NewEntry !=3D NULL); > + > NewEntry->BackLink =3D PrevEntry; > NewEntry->ForwardLink =3D PrevEntry->ForwardLink; > PrevEntry->ForwardLink->BackLink =3D NewEntry; > PrevEntry->ForwardLink =3D NewEntry; > } >=20 >=20 > /** > Insert a new node entry before a designated node entry of a doubly lin= ked > list. >=20 > + ASSERT if PostEntry or NewEntry is NULL. > + > Inserts a new node entry donated by NewEntry after the node entry > donated by PostEntry > of the doubly linked list. >=20 > @param[in, out] PostEntry The entry to insert before. > @param[in, out] NewEntry The new entry to insert. > @@ -1065,10 +1110,12 @@ EFIAPI > NetListInsertBefore ( > IN OUT LIST_ENTRY *PostEntry, > IN OUT LIST_ENTRY *NewEntry > ) > { > + ASSERT (PostEntry !=3D NULL && NewEntry !=3D NULL); > + > NewEntry->ForwardLink =3D PostEntry; > NewEntry->BackLink =3D PostEntry->BackLink; > PostEntry->BackLink->ForwardLink =3D NewEntry; > PostEntry->BackLink =3D NewEntry; > } > @@ -1263,11 +1310,10 @@ NetMapClean ( >=20 > If the number of the pairs in the netmap is zero, return = TRUE. >=20 > If Map is NULL, then ASSERT(). >=20 > - > @param[in] Map The net map to test. >=20 > @return TRUE if the netmap is empty, otherwise FALSE. >=20 > **/ > @@ -1283,10 +1329,12 @@ NetMapIsEmpty ( >=20 >=20 > /** > Return the number of the pairs in the netmap. >=20 > + If Map is NULL, then ASSERT(). > + > @param[in] Map The netmap to get the entry number. >=20 > @return The entry number in the netmap. >=20 > **/ > @@ -1294,10 +1342,11 @@ UINTN > EFIAPI > NetMapGetCount ( > IN NET_MAP *Map > ) > { > + ASSERT (Map !=3D NULL); > return Map->Count; > } >=20 >=20 > /** > @@ -1358,10 +1407,11 @@ NetMapAllocItem ( > Allocate an item to save the pair and add corresponding n= ode > entry > to the beginning of the Used doubly linked list. The number of the Value> > pairs in the netmap increase by 1. >=20 > If Map is NULL, then ASSERT(). > + If Key is NULL, then ASSERT(). >=20 > @param[in, out] Map The netmap to insert into. > @param[in] Key The user's key. > @param[in] Value The user's value for the key. >=20 > @@ -1377,11 +1427,11 @@ NetMapInsertHead ( > IN VOID *Value OPTIONAL > ) > { > NET_MAP_ITEM *Item; >=20 > - ASSERT (Map !=3D NULL); > + ASSERT (Map !=3D NULL && Key !=3D NULL); >=20 > Item =3D NetMapAllocItem (Map); >=20 > if (Item =3D=3D NULL) { > return EFI_OUT_OF_RESOURCES; > @@ -1402,10 +1452,11 @@ NetMapInsertHead ( > Allocate an item to save the pair and add corresponding n= ode > entry > to the tail of the Used doubly linked list. The number of the > pairs in the netmap increase by 1. >=20 > If Map is NULL, then ASSERT(). > + If Key is NULL, then ASSERT(). >=20 > @param[in, out] Map The netmap to insert into. > @param[in] Key The user's key. > @param[in] Value The user's value for the key. >=20 > @@ -1421,11 +1472,11 @@ NetMapInsertTail ( > IN VOID *Value OPTIONAL > ) > { > NET_MAP_ITEM *Item; >=20 > - ASSERT (Map !=3D NULL); > + ASSERT (Map !=3D NULL && Key !=3D NULL); >=20 > Item =3D NetMapAllocItem (Map); >=20 > if (Item =3D=3D NULL) { > return EFI_OUT_OF_RESOURCES; > @@ -1442,10 +1493,13 @@ NetMapInsertTail ( >=20 >=20 > /** > Check whether the item is in the Map and return TRUE if it is. >=20 > + If Map is NULL, then ASSERT(). > + If Item is NULL, then ASSERT(). > + > @param[in] Map The netmap to search within. > @param[in] Item The item to search. >=20 > @return TRUE if the item is in the netmap, otherwise FALSE. >=20 > @@ -1456,10 +1510,12 @@ NetItemInMap ( > IN NET_MAP_ITEM *Item > ) > { > LIST_ENTRY *ListEntry; >=20 > + ASSERT (Map !=3D NULL && Item !=3D NULL); > + > NET_LIST_FOR_EACH (ListEntry, &Map->Used) { > if (ListEntry =3D=3D &Item->Link) { > return TRUE; > } > } > @@ -1473,10 +1529,11 @@ NetItemInMap ( >=20 > Iterate the Used doubly linked list of the netmap to get every item. > Compare the key of every > item with the key to search. It returns the point to the item contains= the > Key if found. >=20 > If Map is NULL, then ASSERT(). > + If Key is NULL, then ASSERT(). >=20 > @param[in] Map The netmap to search within. > @param[in] Key The key to search. >=20 > @return The point to the item contains the Key, or NULL if Key isn't i= n the > map. > @@ -1490,11 +1547,11 @@ NetMapFindKey ( > ) > { > LIST_ENTRY *Entry; > NET_MAP_ITEM *Item; >=20 > - ASSERT (Map !=3D NULL); > + ASSERT (Map !=3D NULL && Key !=3D NULL); >=20 > NET_LIST_FOR_EACH (Entry, &Map->Used) { > Item =3D NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); >=20 > if (Item->Key =3D=3D Key) { > @@ -2093,10 +2150,13 @@ NetLibGetVlanHandle ( > } >=20 > /** > Get MAC address associated with the network service handle. >=20 > + If MacAddress is NULL, then ASSERT(). > + If AddressSize is NULL, then ASSERT(). > + > There should be MNP Service Binding Protocol installed on the input > ServiceHandle. > If SNP is installed on the ServiceHandle or its parent handle, MAC add= ress > will > be retrieved from SNP. If no SNP found, try to get SNP mode data use M= NP. >=20 > @param[in] ServiceHandle The handle where network service binding > protocols are > @@ -2197,10 +2257,12 @@ NetLibGetMacAddress ( >=20 > /** > Convert MAC address of the NIC associated with specified Service Bindi= ng > Handle > to a unicode string. Callers are responsible for freeing the string st= orage. >=20 > + If MacString is NULL, then ASSERT(). > + > Locate simple network protocol associated with the Service Binding Han= dle > and > get the mac address from SNP. Then convert the mac address into a > unicode > string. It takes 2 unicode characters to represent a 1 byte binary buf= fer. > Plus one unicode character for the null-terminator. >=20 > @@ -2296,10 +2358,12 @@ NetLibGetMacString ( > } >=20 > /** > Detect media status for specified network device. >=20 > + If MediaPresent is NULL, then ASSERT(). > + > The underlying UNDI driver may or may not support reporting media stat= us > from > GET_STATUS command > (PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED). This routine > will try to invoke Snp->GetStatus() to get the media status: if media = already > present, it return directly; if media not present, it will stop SNP an= d then > restart SNP to get the latest media status, this give chance to get th= e > correct > @@ -2404,10 +2468,14 @@ NetLibDetectMedia ( > MCastFilter =3D AllocateCopyPool ( > MCastFilterCount * sizeof (EFI_MAC_ADDRESS), > Snp->Mode->MCastFilter > ); > ASSERT (MCastFilter !=3D NULL); > + if (MCastFilter =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto Exit; > + } >=20 > ResetMCastFilters =3D FALSE; > } >=20 > // > @@ -2735,10 +2803,12 @@ ON_EXIT: > } >=20 > /** > Create an IPv4 device path node. >=20 > + If Node is NULL, then ASSERT(). > + > The header type of IPv4 device path node is MESSAGING_DEVICE_PATH. > The header subtype of IPv4 device path node is MSG_IPv4_DP. > Get other info from parameters to make up the whole IPv4 device path > node. >=20 > @param[in, out] Node Pointer to the IPv4 device path= node. > @@ -2762,10 +2832,12 @@ NetLibCreateIPv4DPathNode ( > IN UINT16 RemotePort, > IN UINT16 Protocol, > IN BOOLEAN UseDefaultAddress > ) > { > + ASSERT (Node !=3D NULL); > + > Node->Header.Type =3D MESSAGING_DEVICE_PATH; > Node->Header.SubType =3D MSG_IPv4_DP; > SetDevicePathNodeLength (&Node->Header, sizeof (IPv4_DEVICE_PATH)); >=20 > CopyMem (&Node->LocalIpAddress, &LocalIp, sizeof (EFI_IPv4_ADDRESS)); > @@ -2792,10 +2864,14 @@ NetLibCreateIPv4DPathNode ( > } >=20 > /** > Create an IPv6 device path node. >=20 > + If Node is NULL, then ASSERT(). > + If LocalIp is NULL, then ASSERT(). > + If RemoteIp is NULL, then ASSERT(). > + > The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. > The header subtype of IPv6 device path node is MSG_IPv6_DP. > Get other info from parameters to make up the whole IPv6 device path > node. >=20 > @param[in, out] Node Pointer to the IPv6 device path= node. > @@ -2817,10 +2893,12 @@ NetLibCreateIPv6DPathNode ( > IN EFI_IPv6_ADDRESS *RemoteIp, > IN UINT16 RemotePort, > IN UINT16 Protocol > ) > { > + ASSERT (Node !=3D NULL && LocalIp !=3D NULL && RemoteIp !=3D NULL); > + > Node->Header.Type =3D MESSAGING_DEVICE_PATH; > Node->Header.SubType =3D MSG_IPv6_DP; > SetDevicePathNodeLength (&Node->Header, sizeof (IPv6_DEVICE_PATH)); >=20 > CopyMem (&Node->LocalIpAddress, LocalIp, sizeof (EFI_IPv6_ADDRESS)); > @@ -2841,10 +2919,12 @@ NetLibCreateIPv6DPathNode ( > } >=20 > /** > Find the UNDI/SNP handle from controller and protocol GUID. >=20 > + If ProtocolGuid is NULL, then ASSERT(). > + > For example, IP will open a MNP child to transmit/receive > packets, when MNP is stopped, IP should also be stopped. IP > needs to find its own private data which is related the IP's > service binding instance that is install on UNDI/SNP handle. > Now, the controller is either a MNP or ARP child handle. But > @@ -2868,10 +2948,12 @@ NetLibGetNicHandle ( > EFI_HANDLE Handle; > EFI_STATUS Status; > UINTN OpenCount; > UINTN Index; >=20 > + ASSERT (ProtocolGuid !=3D NULL); > + > Status =3D gBS->OpenProtocolInformation ( > Controller, > ProtocolGuid, > &OpenBuffer, > &OpenCount > @@ -3149,10 +3231,12 @@ NetLibIp6ToStr ( > } >=20 > /** > This function obtains the system guid from the smbios table. >=20 > + If SystemGuid is NULL, then ASSERT(). > + > @param[out] SystemGuid The pointer of the returned system guid. >=20 > @retval EFI_SUCCESS Successfully obtained the system guid. > @retval EFI_NOT_FOUND Did not find the SMBIOS table. >=20 > @@ -3168,10 +3252,12 @@ NetLibGetSystemGuid ( > SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30Table; > SMBIOS_STRUCTURE_POINTER Smbios; > SMBIOS_STRUCTURE_POINTER SmbiosEnd; > CHAR8 *String; >=20 > + ASSERT (SystemGuid !=3D NULL); > + > SmbiosTable =3D NULL; > Status =3D EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOI= D > **) &Smbios30Table); > if (!(EFI_ERROR (Status) || Smbios30Table =3D=3D NULL)) { > Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) Smbios30Table- > >TableAddress; > SmbiosEnd.Raw =3D (UINT8 *) (UINTN) (Smbios30Table->TableAddress + > Smbios30Table->TableMaximumSize); > @@ -3234,11 +3320,14 @@ NetLibGetSystemGuid ( > } while (Smbios.Raw < SmbiosEnd.Raw); > return EFI_NOT_FOUND; > } >=20 > /** > - Create Dns QName according the queried domain name. > + Create Dns QName according the queried domain name. > + > + If DomainName is NULL, then ASSERT(). > + > QName is a domain name represented as a sequence of labels, > where each label consists of a length octet followed by that > number of octets. The QName terminates with the zero > length octet for the null label of the root. Caller should > take responsibility to free the buffer in returned pointer. > @@ -3260,10 +3349,12 @@ NetLibCreateDnsQName ( > CHAR8 *Header; > CHAR8 *Tail; > UINTN Len; > UINTN Index; >=20 > + ASSERT (DomainName !=3D NULL); > + > QueryName =3D NULL; > QueryNameSize =3D 0; > Header =3D NULL; > Tail =3D NULL; >=20 > -- > 1.9.5.msysgit.1