]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg:Fix the bug the incorrect change of StrCpyS function
authorDandan Bi <dandan.bi@intel.com>
Thu, 17 Sep 2015 07:21:22 +0000 (07:21 +0000)
committerdandanbi <dandanbi@Edk2>
Thu, 17 Sep 2015 07:21:22 +0000 (07:21 +0000)
The pointer to the destination string changed,the max length also changed.Previous change neglect this point.
And base on the code logic,we can use StrCatS to replace StrCpyS.Now this patch is to fix this bug.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18497 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/UefiHiiLib/HiiLib.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c

index bee5e0d22cfabcbba1f20280deadf489e3b26edf..66d72acf27556b82bee1a59a78ff843297dfad52 100644 (file)
@@ -662,7 +662,7 @@ HiiConstructConfigHdr (
   //\r
   // Append L"&NAME="\r
   //\r
-  StrCpyS (String, MaxLen, L"&NAME=");\r
+  StrCatS (ReturnString, MaxLen, L"&NAME=");\r
   String += StrLen (String);\r
 \r
   if (Name != NULL) {\r
@@ -677,7 +677,7 @@ HiiConstructConfigHdr (
   //\r
   // Append L"&PATH="\r
   //\r
-  StrCpyS (String, MaxLen, L"&PATH=");\r
+  StrCatS (ReturnString, MaxLen, L"&PATH=");\r
   String += StrLen (String);\r
 \r
   //\r
index 6923d6c4731667428c73b5f6ab1c73efb26cf464..52aa4d8bcf0b8596f24466e78327ae686d8bfba4 100644 (file)
@@ -1758,7 +1758,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&NAME="\r
   //\r
-  StrCpyS (String, MaxLen, L"&NAME=");\r
+  StrCatS (ReturnString, MaxLen, L"&NAME=");\r
   String += StrLen (String);\r
 \r
   if (Name != NULL) {\r
@@ -1773,7 +1773,7 @@ ConstructConfigHdr (
   //\r
   // Append L"&PATH="\r
   //\r
-  StrCpyS (String, MaxLen, L"&PATH=");\r
+  StrCatS (ReturnString, MaxLen, L"&PATH=");\r
   String += StrLen (String);\r
 \r
   //\r
@@ -2044,14 +2044,10 @@ ExtractConfigRequest (
       StringPtr = *ConfigRequest;\r
 \r
       StrCpyS (StringPtr, MaxLen, ConfigHdr);\r
-      StringPtr += StrLen (StringPtr);\r
 \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
 \r
-      StrCpyS (StringPtr, MaxLen, RequestElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      *StringPtr = L'\0';\r
+      StrCatS (StringPtr, MaxLen, RequestElement);\r
 \r
       FreePool (ConfigHdr);\r
       FreePool (RequestElement);\r
@@ -2152,23 +2148,17 @@ ExtractConfigResp (
       StringPtr = *ConfigResp;\r
 \r
       StrCpyS (StringPtr, MaxLen, ConfigHdr);\r
-      StringPtr += StrLen (StringPtr);\r
 \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
 \r
-      StrCpyS (StringPtr, MaxLen, RequestElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      \r
-      *StringPtr = L'&';\r
-      StringPtr++;\r
 \r
-      StrCpyS (StringPtr, MaxLen, L"VALUE=");\r
-      StringPtr += StrLen (StringPtr);\r
+      StrCatS (StringPtr, MaxLen, RequestElement);\r
+\r
+      StrCatS (StringPtr, MaxLen, L"&");\r
+\r
+      StrCatS (StringPtr, MaxLen, L"VALUE=");\r
 \r
-      StrCpyS (StringPtr, MaxLen, ValueElement);\r
-      StringPtr += StrLen (StringPtr);\r
-      *StringPtr = L'\0';\r
+      StrCatS (StringPtr, MaxLen, ValueElement);\r
 \r
       FreePool (ConfigHdr);\r
       FreePool (RequestElement);\r
@@ -2452,43 +2442,33 @@ GenerateKeywordResp (
   // 2.1 Copy NameSpaceId section.\r
   //\r
   StrCpyS (RespStr, RespStrLen, L"NAMESPACE=");\r
-  RespStr += StrLen (RespStr);\r
-  StrCpyS (RespStr, RespStrLen, UnicodeNameSpace);\r
-  RespStr += StrLen (RespStr);\r
+\r
+  StrCatS (RespStr, RespStrLen, UnicodeNameSpace);\r
 \r
   //\r
   // 2.2 Copy PathHdr section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, PathHdr);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, PathHdr);\r
 \r
   //\r
   // 2.3 Copy Keyword section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, L"KEYWORD=");\r
-  RespStr += StrLen (RespStr);\r
-  StrCpyS (RespStr, RespStrLen, KeywordData);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, L"KEYWORD=");\r
+\r
+  StrCatS (RespStr, RespStrLen, KeywordData);\r
 \r
   //\r
   // 2.4 Copy the Value section.\r
   //\r
-  StrCpyS (RespStr, RespStrLen, ValueStr);\r
-  RespStr += StrLen (RespStr);\r
+  StrCatS (RespStr, RespStrLen, ValueStr);\r
 \r
   //\r
   // 2.5 Copy ReadOnly section if exist.\r
   //\r
   if (ReadOnly) {\r
-    StrCpyS (RespStr, RespStrLen, L"&READONLY");\r
-    RespStr += StrLen (RespStr);\r
+    StrCatS (RespStr, RespStrLen, L"&READONLY");\r
   }\r
 \r
-  //\r
-  // 2.6 Add the end.\r
-  //\r
-  *RespStr = L'\0';\r
-\r
   if (UnicodeNameSpace != NULL) {\r
     FreePool (UnicodeNameSpace);\r
   }\r
@@ -2536,12 +2516,9 @@ MergeToMultiKeywordResp (
   FreePool (*MultiKeywordResp);\r
   *MultiKeywordResp = StringPtr;\r
 \r
-  StringPtr += StrLen (StringPtr);\r
-\r
-  *StringPtr = L'&';\r
-  StringPtr++;\r
+  StrCatS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), L"&");\r
 \r
-  StrCpyS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), *KeywordResp);\r
+  StrCatS (StringPtr, MultiKeywordRespLen / sizeof (CHAR16), *KeywordResp);\r
 \r
   return EFI_SUCCESS;\r
 }\r