summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-07-09 05:19:24 +0000
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>2014-07-09 05:19:24 +0000
commit720f84a9d3b53ee567aa90c2362f4c4912d271de (patch)
treea06e70bd79cd6c0a0a8ad8cfb9656dc68d76cc59 /MdeModulePkg
parente364478661e2a5e9195ce4a9f00761e154e48bfa (diff)
downloadedk2-platforms-720f84a9d3b53ee567aa90c2362f4c4912d271de.tar.xz
The UEFI specification does not say anything when the pointers passed to
WaitForEvent() are NULL. Passing NULL pointer would cause a segmentation fault in the current code. This change prevents to get segmentation faults in this case. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15643 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Dxe/Event/Event.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/Event/Event.c
index 1a25b17178..31003a2a56 100644
--- a/MdeModulePkg/Core/Dxe/Event/Event.c
+++ b/MdeModulePkg/Core/Dxe/Event/Event.c
@@ -1,7 +1,7 @@
/** @file
UEFI Event support functions implemented in this file.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, 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
@@ -673,6 +673,14 @@ CoreWaitForEvent (
return EFI_UNSUPPORTED;
}
+ if (NumberOfEvents == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (UserEvents == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
for(;;) {
for(Index = 0; Index < NumberOfEvents; Index++) {
@@ -683,7 +691,9 @@ CoreWaitForEvent (
// provide index of event that caused problem
//
if (Status != EFI_NOT_READY) {
- *UserIndex = Index;
+ if (UserIndex != NULL) {
+ *UserIndex = Index;
+ }
return Status;
}
}