From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 A8701223DB78C for ; Thu, 8 Feb 2018 23:58:01 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2018 00:03:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,482,1511856000"; d="scan'208";a="202604111" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 09 Feb 2018 00:03:46 -0800 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Liming Gao , Star Zeng , Jiewen Yao Date: Fri, 9 Feb 2018 16:03:38 +0800 Message-Id: <1518163418-23228-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" 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: , X-List-Received-Date: Fri, 09 Feb 2018 07:58:02 -0000 "Token" is passed through the perf entry, it's may be NULL. So we need to add NULL pointer check before reference it. Cc: Liming Gao Cc: Star Zeng Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 6 +++++- MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c | 6 +++++- MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 8363b0e..9b3224e 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -113,10 +113,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -845,11 +849,11 @@ InsertFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 79b67e8..f770a35 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -47,10 +47,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -264,11 +268,11 @@ InsertPeiFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 2834a68..dbc1166 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -83,10 +83,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -495,11 +499,11 @@ InsertFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. -- 1.9.5.msysgit.1