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.88; helo=mga01.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 2030E2242383D for ; Wed, 28 Feb 2018 22:23:27 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2018 22:29:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,407,1515484800"; d="scan'208";a="21686496" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.134]) by orsmga008.jf.intel.com with ESMTP; 28 Feb 2018 22:29:34 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Thu, 1 Mar 2018 14:29:31 +0800 Message-Id: <20180301062932.14280-1-jiaxin.wu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [Patch] NetworkPkg/HttpBootDxe: Correct the parameter check for the usage of HttpBootGetFileFromCache. 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: Thu, 01 Mar 2018 06:23:28 -0000 The patch is to fix the incorrect parameter check for the HttpBootGetFileFromCache(). Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c index 15e0ab9d69..b93e63bb2f 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -1,9 +1,9 @@ /** @file Implementation of the boot file download function. -Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
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 full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -434,11 +434,11 @@ HttpBootDhcp6ExtractUriInfo ( goto Error; } } // - // 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. // Status = HttpUrlGetIp6 ( Private->BootFileUri, Private->BootFileUriParser, @@ -744,23 +744,22 @@ HttpBootGetFileFromCache ( LIST_ENTRY *Entry2; HTTP_BOOT_CACHE_CONTENT *Cache; HTTP_BOOT_ENTITY_DATA *EntityData; UINTN CopyedSize; - if (Uri == NULL || BufferSize == 0 || Buffer == NULL || ImageType == NULL) { + if (Uri == NULL || BufferSize == NULL || Buffer == NULL || ImageType == NULL) { return EFI_INVALID_PARAMETER; } NET_LIST_FOR_EACH (Entry, &Private->CacheList) { Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link); // // Compare the URI to see whether we already have a cache for this file. // if ((Cache->RequestData != NULL) && (Cache->RequestData->Url != NULL) && - (StrCmp (Uri, Cache->RequestData->Url) == 0)) - { + (StrCmp (Uri, Cache->RequestData->Url) == 0)) { // // Hit in cache, record image type. // *ImageType = Cache->ImageType; @@ -945,11 +944,11 @@ HttpBootGetBootFile ( Url = AllocatePool (UrlSize * sizeof (CHAR16)); if (Url == NULL) { return EFI_OUT_OF_RESOURCES; } AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize); - if (!HeaderOnly) { + if (!HeaderOnly && Buffer != NULL) { Status = HttpBootGetFileFromCache (Private, Url, BufferSize, Buffer, ImageType); if (Status != EFI_NOT_FOUND) { FreePool (Url); return Status; } @@ -1127,11 +1126,11 @@ HttpBootGetBootFile ( Context.Buffer = Buffer; Context.BufferSize = *BufferSize; Context.Cache = Cache; Context.Private = Private; Status = HttpInitMsgParser ( - HeaderOnly? HttpMethodHead : HttpMethodGet, + HeaderOnly ? HttpMethodHead : HttpMethodGet, ResponseData->Response.StatusCode, ResponseData->HeaderCount, ResponseData->Headers, HttpBootGetBootFileCallback, (VOID*) &Context, -- 2.16.2.windows.1