<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Reviewed-by: Andrew Fish <<a href="mailto:afish@apple.com" class="">afish@apple.com</a>><br class=""><div><br class=""></div><div>Thanks,</div><div><br class=""></div><div>Andrew Fish</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 16, 2019, at 9:58 AM, Carsey, Jaben <<a href="mailto:jaben.carsey@intel.com" class="">jaben.carsey@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Reviewed-by: Jaben Carsey <</span><a href="mailto:jaben.carsey@intel.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">jaben.carsey@intel.com</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Thanks</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">-Jaben</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">-----Original Message-----<br class="">From: Gao, Zhichao<br class="">Sent: Tuesday, July 16, 2019 2:12 AM<br class="">To:<span class="Apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io" class="">devel@edk2.groups.io</a><br class="">Cc: Carsey, Jaben <<a href="mailto:jaben.carsey@intel.com" class="">jaben.carsey@intel.com</a>>; Ni, Ray <<a href="mailto:ray.ni@intel.com" class="">ray.ni@intel.com</a>>;<br class="">Andrew Fish <<a href="mailto:afish@apple.com" class="">afish@apple.com</a>><br class="">Subject: [PATCH V2] ShellPkg/Type.c: Add value check before (LoopVar - 1)<br class=""><br class="">REF: <a href="https://bugzilla.tianocore.org/show_bug.cgi?id=1964" class="">https://bugzilla.tianocore.org/show_bug.cgi?id=1964</a><br class=""><br class="">If the file begin with single line Feed ('\n'), then<br class="">"AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r'"<br class="">would cause a underflow. Add this condition<br class="">"(AsciiChar == '\n' && LoopVar == 0)" before it to make sure<br class="">(LoopVar - 1) would never encounter a underflow.<br class=""><br class="">Same change in Unicode section.<br class=""><br class="">Cc: Jaben Carsey <<a href="mailto:jaben.carsey@intel.com" class="">jaben.carsey@intel.com</a>><br class="">Cc: Ray Ni <<a href="mailto:ray.ni@intel.com" class="">ray.ni@intel.com</a>><br class="">Cc: Andrew Fish <<a href="mailto:afish@apple.com" class="">afish@apple.com</a>><br class="">Signed-off-by: Zhichao Gao <<a href="mailto:zhichao.gao@intel.com" class="">zhichao.gao@intel.com</a>><br class="">---<br class="">V2:<br class="">1. Update the copyright<br class="">2. Fix the same issue in unicode section<br class="">3. Fix typo<br class=""><br class="">.../Library/UefiShellLevel3CommandsLib/Type.c | 24 ++++++++++---------<br class="">1 file changed, 13 insertions(+), 11 deletions(-)<br class=""><br class="">diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c<br class="">b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c<br class="">index 4efc0a8e24..f0aa57af3d 100644<br class="">--- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c<br class="">+++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c<br class="">@@ -2,7 +2,7 @@<br class="">  Main file for Type shell level 3 function.<br class=""><br class="">  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR><br class="">-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. <BR><br class="">+  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved. <BR><br class="">  SPDX-License-Identifier: BSD-2-Clause-Patent<br class=""><br class="">**/<br class="">@@ -78,12 +78,13 @@ TypeFileByHandle (<br class="">          // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)<br class="">          // characters to be displayed as is.<br class="">          //<br class="">-          if (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r') {<br class="">+          if ((AsciiChar == '\n' && LoopVar == 0) ||<br class="">+              (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r')) {<br class="">            //<br class="">-            // In case Line Feed (0xA) is encountered & Carriage Return (0xD)<br class="">-            // was not the previous character, print CR and LF. This is because<br class="">-            // Shell 2.0 requires carriage return with line feed for displaying<br class="">-            // each new line from left.<br class="">+            // In case file begin with single line Feed or Line Feed (0xA) is<br class="">+            // encountered & Carriage Return (0xD) was not previous character,<br class="">+            // print CR and LF. This is because Shell 2.0 requires carriage<br class="">+            // return with line feed for displaying each new line from left.<br class="">            //<br class="">            ShellPrintEx (-1, -1, L"\r\n");<br class="">            continue;<br class="">@@ -121,12 +122,13 @@ TypeFileByHandle (<br class="">          // Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)<br class="">          // characters to be displayed as is.<br class="">          //<br class="">-          if (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r') {<br class="">+          if ((Ucs2Char == '\n' && LoopVar == 0) ||<br class="">+              (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r')) {<br class="">            //<br class="">-            // In case Line Feed (0xA) is encountered & Carriage Return (0xD)<br class="">-            // was not the previous character, print CR and LF. This is because<br class="">-            // Shell 2.0 requires carriage return with line feed for displaying<br class="">-            // each new line from left.<br class="">+            // In case file begin with single line Feed or Line Feed (0xA) is<br class="">+            // encountered & Carriage Return (0xD) was not previous character,<br class="">+            // print CR and LF. This is because Shell 2.0 requires carriage<br class="">+            // return with line feed for displaying each new line from left.<br class="">            //<br class="">            ShellPrintEx (-1, -1, L"\r\n");<br class="">            continue;<br class="">--<br class="">2.21.0.windows.1<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span></div></blockquote></div><br class=""></body></html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/43810">View/Reply Online (#43810)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/32488137/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>