Revision: 17816
          http://sourceforge.net/p/edk2/code/17816
Author:   jcarsey
Date:     2015-07-02 17:26:42 +0000 (Thu, 02 Jul 2015)
Log Message:
-----------
ShellPkg: fix string to number conversion with "0 "

also fixes a few out of date comments.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Tapan Shah <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c

Modified: trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2015-07-02 
10:06:52 UTC (rev 17815)
+++ trunk/edk2/ShellPkg/Library/UefiShellLib/UefiShellLib.c     2015-07-02 
17:26:42 UTC (rev 17816)
@@ -3729,7 +3729,7 @@
 /**
   Convert a Null-terminated Unicode hexadecimal string to a value of type 
UINT64.
 
-  This function returns a value of type UINTN by interpreting the contents
+  This function returns a value of type UINT64 by interpreting the contents
   of the Unicode string specified by String as a hexadecimal number.
   The format of the input Unicode string String is:
 
@@ -3797,16 +3797,16 @@
   Result = 0;
 
   //
-  // Skip spaces if requested
+  // there is a space where there should't be
   //
-  while (StopAtSpace && *String == L' ') {
-    String++;
+  if (*String == L' ') {
+    return (EFI_INVALID_PARAMETER);
   }
 
   while (ShellIsHexaDecimalDigitCharacter (*String)) {
     //
     // If the Hex Number represented by String overflows according
-    // to the range defined by UINTN, then ASSERT().
+    // to the range defined by UINT64, then return EFI_DEVICE_ERROR.
     //
     if (!(Result <= (RShiftU64((((UINT64) ~0) - InternalShellHexCharToUintn 
(*String)), 4)))) {
 //    if (!(Result <= ((((UINT64) ~0) - InternalShellHexCharToUintn (*String)) 
>> 4))) {
@@ -3889,15 +3889,18 @@
   Result = 0;
 
   //
-  // Skip spaces if requested
+  // Stop upon space if requested 
+  // (if the whole value was 0)
   //
-  while (StopAtSpace && *String == L' ') {
-    String++;
+  if (StopAtSpace && *String == L' ') {
+    *Value = Result;
+    return (EFI_SUCCESS);
   }
+
   while (ShellIsDecimalDigitCharacter (*String)) {
     //
     // If the number represented by String overflows according
-    // to the range defined by UINT64, then ASSERT().
+    // to the range defined by UINT64, then return EFI_DEVICE_ERROR.
     //
 
     if (!(Result <= (DivU64x32((((UINT64) ~0) - (*String - L'0')),10)))) {


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to