From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 BFFA081EE2 for ; Wed, 23 Nov 2016 18:56:41 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 23 Nov 2016 18:56:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,689,1473145200"; d="scan'208";a="1089732605" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.34]) by fmsmga002.fm.intel.com with ESMTP; 23 Nov 2016 18:56:40 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu , Jiewen Yao Date: Thu, 24 Nov 2016 10:56:32 +0800 Message-Id: <1479956195-10764-3-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1479956195-10764-1-git-send-email-hao.a.wu@intel.com> References: <1479956195-10764-1-git-send-email-hao.a.wu@intel.com> Subject: [PATCH 2/5] MdeModulePkg/EbcDebugger: Add check for invalid 'CommandArg' X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2016 02:56:41 -0000 Add checks for the return value of function Atoi() in EdbCmdBreakpoint.c. If the input parameter 'CommandArg' contains non-digit character, print corresponding error message. Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- .../Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c index 4be6dd4..f06963f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdBreakpoint.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007 - 2016, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -461,6 +461,10 @@ Returns: // Get breakpoint index // Index = Atoi(CommandArg); + if (Index == (UINTN) -1) { + EDBPrint (L"BreakpointClear Argument error!\n"); + return EFI_DEBUG_CONTINUE; + } if ((Index >= EFI_DEBUGGER_BREAKPOINT_MAX) || (Index >= DebuggerPrivate->DebuggerBreakpointCount)) { @@ -534,6 +538,10 @@ Returns: // Get breakpoint index // Index = Atoi(CommandArg); + if (Index == (UINTN) -1) { + EDBPrint (L"BreakpointDisable Argument error!\n"); + return EFI_DEBUG_CONTINUE; + } // // Disable breakpoint @@ -598,6 +606,10 @@ Returns: // Get breakpoint index // Index = Atoi(CommandArg); + if (Index == (UINTN) -1) { + EDBPrint (L"BreakpointEnable Argument error!\n"); + return EFI_DEBUG_CONTINUE; + } // // Enable breakpoint -- 1.9.5.msysgit.0