summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2014-07-23 11:35:59 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-07-23 11:36:00 -0700
commit6da748a7cebe3911448fabf9426f81c9df9ec54f (patch)
tree913c572e13be5001f2e78ec6f392ba6f193a795d
parentMerge branch 'ta/string-list-init' (diff)
parentunix-socket: remove stale socket before calling chdir() (diff)
downloadtgif-6da748a7cebe3911448fabf9426f81c9df9ec54f.tar.xz
Merge branch 'rs/fix-unlink-unix-socket'
The unix-domain socket used by the sample credential cache daemon tried to unlink an existing stale one at a wrong path, if the path to the socket was given as an overlong path that does not fit in sun_path member of the sockaddr_un structure. * rs/fix-unlink-unix-socket: unix-socket: remove stale socket before calling chdir()
-rw-r--r--unix-socket.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/unix-socket.c b/unix-socket.c
index 01f119f970..91bd6b89d4 100644
--- a/unix-socket.c
+++ b/unix-socket.c
@@ -99,11 +99,12 @@ int unix_stream_listen(const char *path)
struct sockaddr_un sa;
struct unix_sockaddr_context ctx;
+ unlink(path);
+
if (unix_sockaddr_init(&sa, path, &ctx) < 0)
return -1;
fd = unix_stream_socket();
- unlink(path);
if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0)
goto fail;