summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell/ShellManParser.c
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-06-30 03:18:31 +0000
committershenshushi <shenshushi@Edk2>2015-06-30 03:18:31 +0000
commite75390f02971bcd4d67a9696508050bee4936a01 (patch)
tree10fc0928560c01484d1952adf3a5990cc2243c26 /ShellPkg/Application/Shell/ShellManParser.c
parentcb9a7ebabcd6b8a49dc0854b2f9592d732b5afbd (diff)
downloadedk2-platforms-e75390f02971bcd4d67a9696508050bee4936a01.tar.xz
ShellPkg: Use safe string functions to refine code.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17730 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell/ShellManParser.c')
-rw-r--r--ShellPkg/Application/Shell/ShellManParser.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Application/Shell/ShellManParser.c
index 30470e1987..78b8decd83 100644
--- a/ShellPkg/Application/Shell/ShellManParser.c
+++ b/ShellPkg/Application/Shell/ShellManParser.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell MAN file parser.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
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
@@ -43,8 +43,16 @@ GetManFileName(
} else {
Buffer = AllocateZeroPool(StrSize(ManFileName) + 4*sizeof(CHAR16));
if (Buffer != NULL) {
- StrnCpy(Buffer, ManFileName, StrLen(ManFileName));
- StrnCat(Buffer, L".man", 4);
+ StrnCpyS( Buffer,
+ (StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
+ ManFileName,
+ StrLen(ManFileName)
+ );
+ StrnCatS( Buffer,
+ (StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
+ L".man",
+ 4
+ );
}
}
return (Buffer);
@@ -392,9 +400,9 @@ ManBufferFindTitleSection(
if (TitleString == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- StrnCpy(TitleString, StartString, TitleLength/sizeof(CHAR16) - 1);
- StrnCat(TitleString, Command, TitleLength/sizeof(CHAR16) - 1 - StrLen(TitleString));
- StrnCat(TitleString, EndString, TitleLength/sizeof(CHAR16) - 1 - StrLen(TitleString));
+ StrCpyS(TitleString, TitleLength/sizeof(CHAR16), StartString);
+ StrCatS(TitleString, TitleLength/sizeof(CHAR16), Command);
+ StrCatS(TitleString, TitleLength/sizeof(CHAR16), EndString);
CurrentLocation = StrStr(*Buffer, TitleString);
if (CurrentLocation == NULL){
@@ -418,7 +426,7 @@ ManBufferFindTitleSection(
if (*BriefDesc == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
- StrnCpy(*BriefDesc, CurrentLocation, TitleEnd-CurrentLocation);
+ StrnCpyS(*BriefDesc, (*BriefSize)/sizeof(CHAR16), CurrentLocation, TitleEnd-CurrentLocation);
}
}
@@ -495,8 +503,8 @@ ManFileFindTitleSection(
FreePool(ReadLine);
return (EFI_OUT_OF_RESOURCES);
}
- StrnCpy(TitleString, L".TH ", TitleSize/sizeof(CHAR16) - 1);
- StrnCat(TitleString, Command, TitleSize/sizeof(CHAR16) - 1 - StrLen(TitleString));
+ StrCpyS(TitleString, TitleSize/sizeof(CHAR16), L".TH ");
+ StrCatS(TitleString, TitleSize/sizeof(CHAR16), Command);
TitleLen = StrLen(TitleString);
for (;!ShellFileHandleEof(Handle);Size = 1024) {
@@ -532,7 +540,7 @@ ManFileFindTitleSection(
Status = EFI_OUT_OF_RESOURCES;
break;
}
- StrnCpy(*BriefDesc, TitleEnd, (*BriefSize)/sizeof(CHAR16) - 1);
+ StrCpyS(*BriefDesc, (*BriefSize)/sizeof(CHAR16), TitleEnd);
}
break;
}