NetworkPkg/HttpBootDxe: Correct the parameter check for the usage of HttpBootGetFileFromCache.

The patch is to fix the incorrect parameter check for the HttpBootGetFileFromCache().

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
This commit is contained in:
Jiaxin Wu 2018-03-01 11:52:28 +08:00
parent 5ac0a5450b
commit 951c6e63f8

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of the boot file download function. Implementation of the boot file download function.
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials are licensed and made available under This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution. the terms and conditions of the BSD License that accompanies this distribution.
@ -436,7 +436,7 @@ HttpBootDhcp6ExtractUriInfo (
} }
// //
// Extract the HTTP server Ip frome URL. This is used to Check route table // Extract the HTTP server Ip from URL. This is used to Check route table
// whether can send message to HTTP Server Ip through the GateWay. // whether can send message to HTTP Server Ip through the GateWay.
// //
Status = HttpUrlGetIp6 ( Status = HttpUrlGetIp6 (
@ -746,7 +746,7 @@ HttpBootGetFileFromCache (
HTTP_BOOT_ENTITY_DATA *EntityData; HTTP_BOOT_ENTITY_DATA *EntityData;
UINTN CopyedSize; UINTN CopyedSize;
if (Uri == NULL || BufferSize == 0 || Buffer == NULL || ImageType == NULL) { if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -757,8 +757,7 @@ HttpBootGetFileFromCache (
// //
if ((Cache->RequestData != NULL) && if ((Cache->RequestData != NULL) &&
(Cache->RequestData->Url != NULL) && (Cache->RequestData->Url != NULL) &&
(StrCmp (Uri, Cache->RequestData->Url) == 0)) (StrCmp (Uri, Cache->RequestData->Url) == 0)) {
{
// //
// Hit in cache, record image type. // Hit in cache, record image type.
// //
@ -947,7 +946,7 @@ HttpBootGetBootFile (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize); AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
if (!HeaderOnly) { if (!HeaderOnly && Buffer != NULL) {
Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType); Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType);
if (Status != EFI_NOT_FOUND) { if (Status != EFI_NOT_FOUND) {
FreePool (Url); FreePool (Url);
@ -1129,7 +1128,7 @@ HttpBootGetBootFile (
Context.Cache = Cache; Context.Cache = Cache;
Context.Private = Private; Context.Private = Private;
Status = HttpInitMsgParser ( Status = HttpInitMsgParser (
HeaderOnly? HttpMethodHead : HttpMethodGet, HeaderOnly ? HttpMethodHead : HttpMethodGet,
ResponseData->Response.StatusCode, ResponseData->Response.StatusCode,
ResponseData->HeaderCount, ResponseData->HeaderCount,
ResponseData->Headers, ResponseData->Headers,