Index: components/nacl/loader/nacl_listener.cc |
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc |
index a451895fdd2f88da40c295de531cef1657a2538d..36412af3dc826fedd6e3ff9368fb101b0690f9fd 100644 |
--- a/components/nacl/loader/nacl_listener.cc |
+++ b/components/nacl/loader/nacl_listener.cc |
@@ -336,10 +336,23 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
} |
NaClChromeMainSetUrandomFd(urandom_fd); |
#endif |
+ |
+ // Before starting the launching process, verify if FDs/HANDLEs are properly |
+ // transferred to here. |
+ // These can be stale, if some unexpected error happens in the sender |
+ // process. It sends the IPC message regardless of the errors with deferring |
+ // the error handle to the callee for releasing FDs/HANDLEs properly. |
+ CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit()); |
+ CHECK(params.imc_bootstrap_handle != IPC::InvalidPlatformFileForTransit()); |
+ CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit()); |
+#if defined(OS_MACOSX) |
+ CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit()); |
+#endif |
+ CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle)); |
+ |
struct NaClApp* nap = NULL; |
NaClChromeMainInit(); |
- CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle)); |
crash_info_shmem_.reset(new base::SharedMemory( |
params.crash_info_shmem_handle, false /* not readonly */)); |
CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize)); |
@@ -402,13 +415,11 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
args->number_of_cores = number_of_cores_; |
args->create_memory_object_func = CreateMemoryObject; |
# if defined(OS_MACOSX) |
- CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit()); |
g_shm_fd = IPC::PlatformFileForTransitToPlatformFile(params.mac_shm_fd); |
# endif |
#endif |
DCHECK(params.process_type != nacl::kUnknownNaClProcessType); |
- CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit()); |
NaClHandle irt_handle = |
IPC::PlatformFileForTransitToPlatformFile(params.irt_handle); |
@@ -432,7 +443,6 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
params.version); |
} |
- CHECK(params.imc_bootstrap_handle != IPC::InvalidPlatformFileForTransit()); |
args->imc_bootstrap_handle = |
IPC::PlatformFileForTransitToPlatformFile(params.imc_bootstrap_handle); |
args->enable_debug_stub = params.enable_debug_stub; |