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()
This commit is contained in:
Junio C Hamano 2014-07-23 11:35:59 -07:00
commit 6da748a7ce

View File

@ -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;