Skip to content

Commit

Permalink
Merge branch 'rs/fix-unlink-unix-socket'
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
Junio C Hamano committed Jul 23, 2014
2 parents 955d7be + 2869b3e commit 6da748a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unix-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6da748a

Please sign in to comment.