From 96cc7967879f5a000ebd17ff4fd49b4e5d61db68 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 11 Mar 2014 15:44:54 -0700 Subject: [PATCH] Do not leave console socket lying around in /tmp. --- Console.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Console.cpp b/Console.cpp index f93e090..945b9bc 100644 --- a/Console.cpp +++ b/Console.cpp @@ -814,19 +814,27 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { address.sun_family = AF_UNIX; sprintf(address.sun_path, "/tmp/.s.cy.%u", getpid()); + unlink(address.sun_path); + + struct File { + const char *path_; + + File(const char *path) : + path_(path) + { + } + + ~File() { + unlink(path_); + } + } file(address.sun_path); _syscall(bind(server, reinterpret_cast(&address), SUN_LEN(&address))); _syscall(chmod(address.sun_path, 0777)); - try { - _syscall(listen(server, 1)); - InjectLibrary(pid); - client_ = _syscall(accept(server, NULL, NULL)); - } catch (...) { - // XXX: exception? - unlink(address.sun_path); - throw; - } + _syscall(listen(server, 1)); + InjectLibrary(pid); + client_ = _syscall(accept(server, NULL, NULL)); } catch (...) { _syscall(close(server)); throw; -- 2.47.2