From: Dandan Bi Date: Fri, 9 Feb 2018 05:21:08 +0000 (+0800) Subject: MdeModulePkg/PerfLib: Add NULL pointer check for "Token" X-Git-Tag: edk2-stable201903~2397 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=c9faac275bd80f34b00017ca92ce73beb0c0038f MdeModulePkg/PerfLib: Add NULL pointer check for "Token" "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 Reviewed-by: Liming Gao --- diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 8363b0e4ed..9b3224ef6f 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -115,6 +115,10 @@ 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 || @@ -847,7 +851,7 @@ InsertFpdtMeasurement ( // // 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. diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 79b67e8506..f770a35a99 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -49,6 +49,10 @@ 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 || @@ -266,7 +270,7 @@ InsertPeiFpdtMeasurement ( // // 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. diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 2834a685d7..dbc1166f25 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -85,6 +85,10 @@ 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 || @@ -497,7 +501,7 @@ InsertFpdtMeasurement ( // // 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.