From nobody Mon May 6 00:14:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518512043811661.9231087061976; Tue, 13 Feb 2018 00:54:03 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9474A21CF1D05; Tue, 13 Feb 2018 00:48:11 -0800 (PST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A356421CF1D01 for ; Tue, 13 Feb 2018 00:48:09 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 00:53:58 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by orsmga004.jf.intel.com with ESMTP; 13 Feb 2018 00:53:57 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,506,1511856000"; d="scan'208";a="174504984" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 13 Feb 2018 16:53:55 +0800 Message-Id: <20180213085355.114644-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [edk2] [PATCH] ShellPkg/ShellLib: Fix a bug in InternalShellIsHexOrDecimalNumber X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaben Carsey , Vladimir Olovyannikov MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" InternalShellIsHexOrDecimalNumber() wrongly treats "-" as a number. The patch fixes this issue. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D730 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Vladimir Olovyannikov Cc: Jaben Carsey Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Librar= y/UefiShellLib/UefiShellLib.c index 7f6389f655..e53985e2d7 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -3,7 +3,7 @@ =20 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
Copyright 2016 Dell Inc. - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -3636,29 +3636,36 @@ InternalShellIsHexOrDecimalNumber ( ) { BOOLEAN Hex; + BOOLEAN LeadingZero; + + if (String =3D=3D NULL) { + return FALSE; + } =20 // // chop off a single negative sign // - if (String !=3D NULL && *String =3D=3D L'-') { + if (*String =3D=3D L'-') { String++; } =20 - if (String =3D=3D NULL) { - return (FALSE); + if (*String =3D=3D CHAR_NULL) { + return FALSE; } =20 // // chop leading zeroes // - while(String !=3D NULL && *String =3D=3D L'0'){ + LeadingZero =3D FALSE; + while(*String =3D=3D L'0'){ String++; + LeadingZero =3D TRUE; } // // allow '0x' or '0X', but not 'x' or 'X' // - if (String !=3D NULL && (*String =3D=3D L'x' || *String =3D=3D L'X')) { - if (*(String-1) !=3D L'0') { + if (*String =3D=3D L'x' || *String =3D=3D L'X') { + if (!LeadingZero) { // // we got an x without a preceeding 0 // @@ -3675,7 +3682,7 @@ InternalShellIsHexOrDecimalNumber ( // // loop through the remaining characters and use the lib function // - for ( ; String !=3D NULL && *String !=3D CHAR_NULL && !(StopAtSpace && *= String =3D=3D L' ') ; String++){ + for ( ; *String !=3D CHAR_NULL && !(StopAtSpace && *String =3D=3D L' ') = ; String++){ if (TimeNumbers && (String[0] =3D=3D L':')) { continue; } --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel