From: Jay Freeman (saurik) Date: Tue, 11 Mar 2014 22:44:54 +0000 (-0700) Subject: Do not leave console socket lying around in /tmp. X-Git-Tag: v0.9.502~24 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/96cc7967879f5a000ebd17ff4fd49b4e5d61db68?ds=inline Do not leave console socket lying around in /tmp. --- 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;