From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.6677.1584687347579807799 for ; Thu, 19 Mar 2020 23:55:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: guomin.jiang@intel.com) IronPort-SDR: nqnaPOlcsbY6VCmHeN75adQFajb6nQN3W2rZZCH1yrH3Kbjm5/uKsXDaymqUmAXcyhlTU7QjkQ cderbrfoLY7g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2020 23:55:47 -0700 IronPort-SDR: g44Cqe+2Q2xVFggp5H6fmMOVkBgDmiIv/Zb62iRxsD9XLUF7rXYmfBRBxcc5NcyZGuCO/Vo1Nj 7Ui8M+aj3kmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,283,1580803200"; d="scan'208";a="248790383" Received: from guominji-mobl.ccr.corp.intel.com ([10.238.5.173]) by orsmga006.jf.intel.com with ESMTP; 19 Mar 2020 23:55:44 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jordan Justen , Andrew Fish , Ray Ni Subject: [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status. Date: Fri, 20 Mar 2020 14:55:43 +0800 Message-Id: <20200320065543.602-1-guomin.jiang@intel.com> X-Mailer: git-send-email 2.25.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2605 I think it is necessary that check the buffer size before ReadFile, it will inform the caller that they should provide more buffer. Cc: Jordan Justen Cc: Andrew Fish Cc: Ray Ni Signed-off-by: Guomin Jiang --- EmulatorPkg/Win/Host/WinFileSystem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/EmulatorPkg/Win/Host/WinFileSystem.c b/EmulatorPkg/Win/Host/Wi= nFileSystem.c index f6b06b1c92..6fb86db6b3 100644 --- a/EmulatorPkg/Win/Host/WinFileSystem.c +++ b/EmulatorPkg/Win/Host/WinFileSystem.c @@ -1159,6 +1159,12 @@ WinNtFileRead ( }=0D }=0D =0D + if (FileSize > *BufferSize) {=0D + Status =3D EFI_BUFFER_TOO_SMALL;=0D + *BufferSize =3D FileSize;=0D + goto Done;=0D + }=0D +=0D Status =3D ReadFile (=0D PrivateFile->LHandle,=0D Buffer,=0D --=20 2.25.1.windows.1