//\r
// Close the previously openned IP protocol.\r
//\r
- gBS->CloseProtocol (\r
- ChildHandle,\r
- IpProtocolGuid,\r
- ImageHandle,\r
- ControllerHandle\r
- );\r
+ Status = gBS->CloseProtocol (\r
+ ChildHandle,\r
+ IpProtocolGuid,\r
+ ImageHandle,\r
+ ControllerHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
//\r
// Destroy the IP child.\r
//\r
- Status = NetLibDestroyServiceChild (\r
- ControllerHandle,\r
- ImageHandle,\r
- ServiceBindingGuid,\r
- ChildHandle\r
- );\r
-\r
- return Status;\r
+ return NetLibDestroyServiceChild (\r
+ ControllerHandle,\r
+ ImageHandle,\r
+ ServiceBindingGuid,\r
+ ChildHandle\r
+ );\r
}\r
\r
/**\r
TrimBytes = (UINT32) (PayLoadHdr - (UINT8 *) IcmpHdr);\r
\r
NetbufTrim (Pkt, TrimBytes, TRUE);\r
-\r
- IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);\r
+ \r
+ //\r
+ // If the input packet has invalid format, and TrimBytes is larger than \r
+ // the packet size, the NetbufTrim might trim the packet to zero.\r
+ //\r
+ if (Pkt->TotalSize != 0) {\r
+ IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);\r
+ }\r
\r
return EFI_SUCCESS; \r
}\r
\r
NetbufTrim (Pkt, TrimBytes, TRUE);\r
\r
- IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);\r
+ //\r
+ // If the input packet has invalid format, and TrimBytes is larger than \r
+ // the packet size, the NetbufTrim might trim the packet to zero.\r
+ //\r
+ if (Pkt->TotalSize != 0) {\r
+ IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);\r
+ }\r
\r
return EFI_SUCCESS;\r
}\r
IN IP_IO_IP_INFO *Sender OPTIONAL,\r
IN VOID *Context OPTIONAL,\r
IN VOID *NotifyData OPTIONAL,\r
- IN EFI_IP_ADDRESS *Dest,\r
+ IN EFI_IP_ADDRESS *Dest OPTIONAL,\r
IN IP_IO_OVERRIDE *OverrideData OPTIONAL\r
)\r
{\r
}\r
\r
if (IpConfigData != NULL) {\r
- if (IpInfo->IpVersion == IP_VERSION_4){\r
+ if (IpInfo->IpVersion == IP_VERSION_4) {\r
\r
if (((EFI_IP4_CONFIG_DATA *) IpConfigData)->UseDefaultAddress) {\r
- Ip.Ip4->GetModeData (\r
- Ip.Ip4, \r
- &Ip4ModeData, \r
- NULL, \r
- NULL\r
- );\r
+ Status = Ip.Ip4->GetModeData (\r
+ Ip.Ip4, \r
+ &Ip4ModeData, \r
+ NULL, \r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Ip.Ip4->Configure (Ip.Ip4, NULL);\r
+ goto OnExit;\r
+ }\r
\r
IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)->StationAddress, &Ip4ModeData.ConfigData.StationAddress);\r
IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)->SubnetMask, &Ip4ModeData.ConfigData.SubnetMask);\r
- }\r
+ }\r
\r
CopyMem (\r
&IpInfo->Addr.Addr, \r
Ip.Ip4,\r
&IpInfo->DummyRcvToken.Ip4Token\r
);\r
- if (EFI_ERROR (Status)) {\r
- Ip.Ip4->Configure (Ip.Ip4, NULL);\r
- }\r
- } else {\r
- Ip.Ip6->GetModeData (\r
- Ip.Ip6,\r
- &Ip6ModeData,\r
- NULL,\r
- NULL\r
- );\r
+ if (EFI_ERROR (Status)) {\r
+ Ip.Ip4->Configure (Ip.Ip4, NULL);\r
+ }\r
+ } else {\r
+ Status = Ip.Ip6->GetModeData (\r
+ Ip.Ip6,\r
+ &Ip6ModeData,\r
+ NULL,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Ip.Ip6->Configure (Ip.Ip6, NULL);\r
+ goto OnExit;\r
+ }\r
\r
if (Ip6ModeData.IsConfigured) {\r
CopyMem (\r