From nobody Wed May 1 23:35:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1524723504586115.34247801218567; Wed, 25 Apr 2018 23:18:24 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 10678203569A0; Wed, 25 Apr 2018 23:18:23 -0700 (PDT) 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 144F520356997 for ; Wed, 25 Apr 2018 23:18:22 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 23:18:21 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.84]) by fmsmga006.fm.intel.com with ESMTP; 25 Apr 2018 23:18:20 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,329,1520924400"; d="scan'208";a="223513248" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Thu, 26 Apr 2018 14:18:13 +0800 Message-Id: <20180426061813.12012-1-jiaxin.wu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [edk2] [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Jaben Carsey , Fu Siyuan , Wu Jiaxin , Vladimir Olovyannikov MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch is to fix the issue reported from https://bugzilla.tianocore.org/show_bug.cgi?id=3D925. DataSize variable was not assigned the value if ShellOpenFileByName returns= error. In the such a case, it should not be used to FreePages. Instead, DataSize c= an be used to record the file size once DownloadFile successfully. Cc: Vladimir Olovyannikov Cc: Ye Ting Cc: Fu Siyuan Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg/D= ynamicCommand/TftpDynamicCommand/Tftp.c index 8569c966dd..0620aec1a7 100644 --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c @@ -1,10 +1,10 @@ /** @file The implementation for the 'tftp' Shell command. =20 Copyright (c) 2015, ARM Ltd. All rights reserved.
- Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
=20 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 @@ -517,10 +517,12 @@ RunTftp ( mTftpHiiHandle, RemoteFilePath, NicName, Status ); goto NextHandle; } =20 + DataSize =3D FileSize; + if (!EFI_ERROR (ShellFileExists (LocalFilePath))) { ShellDeleteFileByName (LocalFilePath); } =20 Status =3D ShellOpenFileByName ( @@ -537,11 +539,10 @@ RunTftp ( mTftpHiiHandle, L"tftp", LocalFilePath ); goto NextHandle; } =20 - DataSize =3D FileSize; Status =3D ShellWriteFile (FileHandle, &FileSize, Data); if (!EFI_ERROR (Status)) { ShellStatus =3D SHELL_SUCCESS; } else { ShellPrintHiiEx ( --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel