NetworkPkg: Code logic optimization for DnsDxe and HttpDxe driver

Revise some errors which may lead NULL pointer be dereferenced:
* DnsDhcp.c: Paralist may be used without any initialized
* DnsHeader and RcvString may be null but be dereferenced
* HttpDriver.c: revise an if judgment
* HttpImpl.c: add a judgment to avoid null dereferenced

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: fanwang2 <fan.wang@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17923 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
fanwang2 2015-07-10 09:00:33 +00:00 committed by fanwang2
parent 6b6fe3e9aa
commit 3fd7bd08f4
4 changed files with 10 additions and 2 deletions

View File

@ -301,6 +301,8 @@ GetDns4ServerFromDhcp4 (
Data = NULL;
InterfaceInfo = NULL;
ZeroMem ((UINT8 *) ParaList, sizeof (ParaList));
ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA));
ZeroMem (&DnsServerInfor, sizeof (DNS4_SERVER_INFOR));

View File

@ -1049,6 +1049,7 @@ IsValidDnsResponse (
continue;
} else {
TxString = NetbufGetByte (Packet, 0, NULL);
ASSERT (TxString != NULL);
DnsHeader = (DNS_HEADER *) TxString;
QueryName = (CHAR8 *) (TxString + sizeof (*DnsHeader));
QuerySection = (DNS_QUERY_SECTION *) (QueryName + AsciiStrLen (QueryName) + 1);
@ -1426,7 +1427,8 @@ DnsOnPacketReceived (
ASSERT (Packet != NULL);
RcvString = NetbufGetByte (Packet, 0, NULL);
ASSERT (RcvString != NULL);
//
// Parse Dns Response
//

View File

@ -79,7 +79,7 @@ HttpCleanService (
IN HTTP_SERVICE *HttpService
)
{
if (HttpService != NULL) {
if (HttpService == NULL) {
return ;
}

View File

@ -766,6 +766,10 @@ HttpResponseWorker (
HTTP_TOKEN_WRAP *ValueInItem;
UINTN HdrLen;
if (Wrap == NULL || Wrap->HttpInstance == NULL) {
return EFI_INVALID_PARAMETER;
}
HttpInstance = Wrap->HttpInstance;
Token = Wrap->HttpToken;