]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fixed memory leak and buffer overrun for string op-code.
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Aug 2011 01:54:49 +0000 (01:54 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Aug 2011 01:54:49 +0000 (01:54 +0000)
Signed-off-by:ydong10
Reviewed-by:lgao4

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12213 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Setup.c

index 65ce5bddcec4085ae29f464c949c2e12d2640dd9..0b526d0a02ff8ed1209dfd90089bb9d6019ddb74 100644 (file)
@@ -2596,7 +2596,11 @@ GetQuestionDefault (
           if (StrValue == NULL) {\r
             return EFI_NOT_FOUND;\r
           }\r
-          Question->BufferValue = AllocateCopyPool (StrSize (StrValue), StrValue);\r
+          if (Question->StorageWidth > StrSize (StrValue)) {\r
+            CopyMem (Question->BufferValue, StrValue, StrSize (StrValue));\r
+          } else {\r
+            CopyMem (Question->BufferValue, StrValue, Question->StorageWidth);\r
+          }\r
         }\r
 \r
         return EFI_SUCCESS;\r