From 42d31d64dd11c8e9c506df32c2687648527921a7 Mon Sep 17 00:00:00 2001 From: Cervantes Yu Date: Tue, 7 Jul 2015 12:10:05 +0800 Subject: [PATCH] Bug 1172467: Fix an IPC channel file descriptor leak from Nuwa to the child process. r=khuey --- ipc/glue/ProcessUtils_linux.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ipc/glue/ProcessUtils_linux.cpp b/ipc/glue/ProcessUtils_linux.cpp index 7ad56b81e13..0d9b66f3a91 100644 --- a/ipc/glue/ProcessUtils_linux.cpp +++ b/ipc/glue/ProcessUtils_linux.cpp @@ -375,17 +375,16 @@ ProcLoaderLoadRunner::ShuffleFds() MOZ_ASSERT(mFdsRemap.Length() <= kReservedFileDescriptors); - InjectiveMultimap fd_shuffle1, fd_shuffle2; - fd_shuffle1.reserve(mFdsRemap.Length()); - fd_shuffle2.reserve(mFdsRemap.Length()); + InjectiveMultimap fd_shuffle; + fd_shuffle.reserve(mFdsRemap.Length()); for (i = 0; i < mFdsRemap.Length(); i++) { const FDRemap *map = &mFdsRemap[i]; int fd = map->fd().PlatformHandle(); int tofd = map->mapto(); - fd_shuffle1.push_back(InjectionArc(fd, tofd, false)); - fd_shuffle2.push_back(InjectionArc(fd, tofd, false)); + // The FD that is dup2()'d from needs to be closed after shuffling. + fd_shuffle.push_back(InjectionArc(fd, tofd, /*in_close=*/true)); // Erase from sReservedFds we will use. for (int* toErase = sReservedFds->begin(); @@ -398,7 +397,7 @@ ProcLoaderLoadRunner::ShuffleFds() } } - DebugOnly ok = ShuffleFileDescriptors(&fd_shuffle1); + DebugOnly ok = ShuffleFileDescriptors(&fd_shuffle); // Close the FDs that are reserved but not used after // ShuffleFileDescriptors().