diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2015-07-09 03:19:06 +0000 |
---|---|---|
committer | shenshushi <shenshushi@Edk2> | 2015-07-09 03:19:06 +0000 |
commit | 4dc0d578b8b923672657956d3b1831c3cbf126ef (patch) | |
tree | b54d4cce8cea477c35194d2266134da75e4aa898 /ShellPkg/Library/UefiShellDebug1CommandsLib | |
parent | 3b87e3881e6ea25885bf445c3d4278f7ef2668c3 (diff) | |
download | edk2-platforms-4dc0d578b8b923672657956d3b1831c3cbf126ef.tar.xz |
ShellPkg: Refine code to use Strn**S safe functions instead of Str**S ones in some cases.
Safe string functions may ASSERT when the source length is larger than the MaxDest. This patch use Strn**S to indicate the copy length.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Tapan Shah <<tapandshah@hp.com>>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17894 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c | 2 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c index d818b9b8d4..ac6d0bdb55 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -406,7 +406,7 @@ CascadeProcessVariables ( FoundVarName = AllocateZeroPool (NameSize);
if (FoundVarName != NULL) {
if (PrevName != NULL) {
- StrCpyS(FoundVarName, NameSize/sizeof(CHAR16), PrevName);
+ StrnCpyS(FoundVarName, NameSize/sizeof(CHAR16), PrevName, NameSize/sizeof(CHAR16) - 1);
}
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c index dd878c4cb7..759f486a32 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c @@ -3229,8 +3229,8 @@ QueryTable ( //
if ((High > Low && Key >= Low && Key <= High)
|| (Table[Index].Key == Key)) {
- StrCpyS (Info, InfoLen, Table[Index].Info);
- StrCatS (Info, InfoLen, L"\n");
+ StrnCpyS (Info, InfoLen, Table[Index].Info, InfoLen - 1);
+ StrnCatS (Info, InfoLen, L"\n", InfoLen - 1 - StrLen(Info));
return Key;
}
}
|