Revision: 13899
          http://edk2.svn.sourceforge.net/edk2/?rev=13899&view=rev
Author:   vanjeff
Date:     2012-10-31 06:46:17 +0000 (Wed, 31 Oct 2012)
Log Message:
-----------
Sync patch r13857 from main trunk.
Fix buffer overflow issue in Consplitter.

Revision Links:
--------------
    http://edk2.svn.sourceforge.net/edk2/?rev=13857&view=rev

Modified Paths:
--------------
    
branches/UDK2010.SR1/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c

Modified: 
branches/UDK2010.SR1/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
===================================================================
--- 
branches/UDK2010.SR1/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
    2012-10-31 03:31:08 UTC (rev 13898)
+++ 
branches/UDK2010.SR1/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
    2012-10-31 06:46:17 UTC (rev 13899)
@@ -2109,6 +2109,8 @@
   INT32 *OldTextOutModeMap;
   INT32 *SrcAddress;
   INT32 Index;
+  UINTN OldStepSize;
+  UINTN NewStepSize;
 
   NewSize           = Private->TextOutListCount * sizeof (INT32);
   OldTextOutModeMap = Private->TextOutModeMap;
@@ -2146,14 +2148,26 @@
     Size        = Private->CurrentNumberOfConsoles * sizeof (INT32);
     Index       = 0;
     SrcAddress  = OldTextOutModeMap;
+    NewStepSize = NewSize / sizeof(INT32);    
+    // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
+    // is not NULL, it indicates that the original TextOutModeMap is not enough
+    // for the new console devices and has been enlarged by 
CONSOLE_SPLITTER_ALLOC_UNIT columns.
+    //
+    OldStepSize = NewStepSize - CONSOLE_SPLITTER_ALLOC_UNIT;
 
     //
     // Copy the old data to the new one
     //
     while (Index < Private->TextOutMode.MaxMode) {
       CopyMem (TextOutModeMap, SrcAddress, Size);
-      TextOutModeMap += NewSize;
-      SrcAddress += Size;
+      //
+      // Go to next row of new TextOutModeMap.
+      //
+      TextOutModeMap += NewStepSize;
+      //
+      // Go to next row of old TextOutModeMap.
+      //
+      SrcAddress += OldStepSize;
       Index++;
     }
     //
@@ -3185,6 +3199,35 @@
     return EFI_NOT_FOUND;
   }
 
+  if ((Private->CurrentNumberOfGraphicsOutput == 0) && 
(Private->CurrentNumberOfUgaDraw == 0)) {
+    //
+    // If there is not any physical GOP and UGA device in system,
+    // Consplitter GOP or UGA protocol will be uninstalled
+    //
+    if (!FeaturePcdGet (PcdConOutGopSupport)) {
+      Status = gBS->UninstallProtocolInterface (
+                      Private->VirtualHandle,
+                      &gEfiUgaDrawProtocolGuid,
+                      &Private->UgaDraw
+                      );      
+    } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {
+      Status = gBS->UninstallProtocolInterface (
+                      Private->VirtualHandle,
+                      &gEfiGraphicsOutputProtocolGuid,
+                      &Private->GraphicsOutput
+                      );
+    } else {
+      Status = gBS->UninstallMultipleProtocolInterfaces (
+             Private->VirtualHandle,
+             &gEfiUgaDrawProtocolGuid,
+             &Private->UgaDraw,
+             &gEfiGraphicsOutputProtocolGuid,
+             &Private->GraphicsOutput,
+             NULL
+             );
+    }
+  }
+
   if (CurrentNumOfConsoles == 0) {
     //
     // If the number of consoles is zero, reset all parameters

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to