From nobody Sun May 5 21:04:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43711+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43711+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563175862; cv=none; d=zoho.com; s=zohoarc; b=Rnzmmsy78sQ/u9GZeJCjFs3Y9OYHW/ZJ9A21v0CizWElM3816YVbdYpsKwTtnK82U91UAyJoWL0hTY0ScBwIwwKnPteF1ZBxvxDgQRNpcztYS6yrSVUx3sxPORfIfxjvCbyosoEJgTnucNm2XmaPKhW4xHMc087Vyl5W2Fo7hW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563175862; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=RcA7rozJtpeNOvBRPx+FWNUituumP0fpSokLQU9thC0=; b=D82VgSUmLD12xrcrds3IDqVt2gHrUXt09DFxYvK1yHMvJ+4ZPcUxxI8KKcBcXDEo19E5zjeDJU+sbzz3Y6gO3q9LwQnJ+nhAURR9JcKsH6EMsiu6mcjOEF0lsnH4M53fiBRUvwEnVuq4fYNaCwvTPhG9M37vvLwKCOaatMUAXUI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43711+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563175861888532.166885284823; Mon, 15 Jul 2019 00:31:01 -0700 (PDT) Return-Path: X-Received: from mga05.intel.com (mga05.intel.com []) by groups.io with SMTP; Mon, 15 Jul 2019 00:31:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jul 2019 00:31:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,493,1557212400"; d="scan'208";a="187064421" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 15 Jul 2019 00:30:59 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jaben Carsey , Ray Ni , Andrew Fish Subject: [edk2-devel] [PATCH] ShellPkg/Type.c: Add value check before (LoopVar - 1) Date: Mon, 15 Jul 2019 15:30:05 +0800 Message-Id: <20190715073007.25732-2-zhichao.gao@intel.com> In-Reply-To: <20190715073007.25732-1-zhichao.gao@intel.com> References: <20190715073007.25732-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563175861; bh=4RnezRCprmAWULQnl8oWZWG239dshRW+qY8S7HvBNRc=; h=Cc:Date:From:Reply-To:Subject:To; b=oN2ueMpG5LQ68cv4dEYL6M9yJWnUbKzag+eBGz9I5yDeREGD+N/duNiUPdgDdFMKCXq iMSBhej3+CyxP8vck+nVVz0MQ6JR+wbcjMpqNzdbFCfAOaEJjEBLYwoARrKc3Sp654Jbr n2XhL9qZ9F0QXftp9mIJsTVPn/HlMn43shY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1964 If the file begin with single line Feed ('\n'), then "AsciiChar =3D=3D '\n' && ((CHAR8*)Buffer)[LoopVar-1] !=3D '\r'" would cause a underflow. Add this condition "(AsciiChar =3D=3D '\n' && LoopVar =3D=3D 0)" before it to make sure (LoopVar - 1) would never encounter a underflow. Cc: Jaben Carsey Cc: Ray Ni Cc: Andrew Fish Signed-off-by: Zhichao Gao --- ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c b/ShellPkg/= Library/UefiShellLevel3CommandsLib/Type.c index 4efc0a8e24..c1f670c713 100644 --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c @@ -78,12 +78,13 @@ TypeFileByHandle ( // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD) // characters to be displayed as is. // - if (AsciiChar =3D=3D '\n' && ((CHAR8*)Buffer)[LoopVar-1] !=3D '\= r') { + if ((AsciiChar =3D=3D '\n' && LoopVar =3D=3D 0) || + (AsciiChar =3D=3D '\n' && ((CHAR8*)Buffer)[LoopVar-1] !=3D '= \r')) { // - // In case Line Feed (0xA) is encountered & Carriage Return (0= xD) - // was not the previous character, print CR and LF. This is be= cause - // Shell 2.0 requires carriage return with line feed for displ= aying - // each new line from left. + // In case file begin with single line Feed or Line Feed (0xA)= is + // encountered & Carriage Return (0xD) was not previous charac= ter, + // print CR and LF. This is because Shell 2.0 requires carriage + // return Swith line feed for displaying each new line from le= ft. // ShellPrintEx (-1, -1, L"\r\n"); continue; --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43711): https://edk2.groups.io/g/devel/message/43711 Mute This Topic: https://groups.io/mt/32476115/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-