From 720f84a9d3b53ee567aa90c2362f4c4912d271de Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Wed, 9 Jul 2014 05:19:24 +0000 Subject: 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 Signed-off-by: Feng Tian Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15643 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Event/Event.c | 14 ++++++++++++-- 1 file 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.
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
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; } } -- cgit v1.2.3