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.web11.6666.1584688334367359694 for ; Fri, 20 Mar 2020 00:12:14 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: ray.ni@intel.com) IronPort-SDR: aEdEkqamfND9y9K5FVt1WKdWBSg0OgtoA3z/eMy6kMqGv6pPmJAUpjmH0RQPd13PH4Wr4CPazv K2wtlbGGARfg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2020 00:12:14 -0700 IronPort-SDR: 7EqQElDAZviOOQTM3oufSuir8EU0ggmtam1eGjwh19zF0zGkQ/9at2UkUiq4EkeOoyySeXtdvi yR8/HWuQdEaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,283,1580803200"; d="scan'208";a="418625498" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 20 Mar 2020 00:12:13 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Mar 2020 00:11:52 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Mar 2020 00:11:51 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.137]) with mapi id 14.03.0439.000; Fri, 20 Mar 2020 15:11:46 +0800 From: "Ni, Ray" To: "Jiang, Guomin" , "devel@edk2.groups.io" CC: "Justen, Jordan L" , Andrew Fish Subject: Re: [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status. Thread-Topic: [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for return status. Thread-Index: AQHV/oSYCxN/pIaaukGrLKbzWUppMqhRD93w Date: Fri, 20 Mar 2020 07:11:45 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C4A2AB8@SHSMSX104.ccr.corp.intel.com> References: <20200320065543.602-1-guomin.jiang@intel.com> In-Reply-To: <20200320065543.602-1-guomin.jiang@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Guomin, It's OK to do a partial read. There is no requirement for a single read that returns all the file content back to caller. Some comments to your commit message: Besides, the commit message is too simple. It should indicate what was wrong in the code and what's your expected behavior. The Bugzilla comments are very detailed actually. Thanks, Ray > -----Original Message----- > From: Jiang, Guomin > Sent: Friday, March 20, 2020 2:56 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L ; Andrew Fish > ; Ni, Ray > Subject: [PATCH] EmulatorPkg/WinHost: Add EFI_BUFFER_TOO_SMALL for > return status. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2605 >=20 > I think it is necessary that check the buffer size before ReadFile, it > will inform the caller that they should provide more buffer. >=20 > 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(+) >=20 > diff --git a/EmulatorPkg/Win/Host/WinFileSystem.c > b/EmulatorPkg/Win/Host/WinFileSystem.c > index f6b06b1c92..6fb86db6b3 100644 > --- a/EmulatorPkg/Win/Host/WinFileSystem.c > +++ b/EmulatorPkg/Win/Host/WinFileSystem.c > @@ -1159,6 +1159,12 @@ WinNtFileRead ( > } >=20 > } >=20 >=20 >=20 > + if (FileSize > *BufferSize) { >=20 > + Status =3D EFI_BUFFER_TOO_SMALL; >=20 > + *BufferSize =3D FileSize; >=20 > + goto Done; >=20 > + } >=20 > + >=20 > Status =3D ReadFile ( >=20 > PrivateFile->LHandle, >=20 > Buffer, >=20 > -- > 2.25.1.windows.1