]> git.ipfire.org Git - thirdparty/git.git/commit - unix-socket.c
unix-socket: disallow chdir() when creating unix domain sockets
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 15 Mar 2021 21:08:26 +0000 (21:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Mar 2021 21:32:51 +0000 (14:32 -0700)
commit77e522caaeebe8c6378dcf7045b19cbd22c8b2fb
treea935ff8bd5ce0802dfda6fbd530e99f07446f491
parent55144ccb0ac48bd2db0b907a8e8123b2befe83d1
unix-socket: disallow chdir() when creating unix domain sockets

Calls to `chdir()` are dangerous in a multi-threaded context.  If
`unix_stream_listen()` or `unix_stream_connect()` is given a socket
pathname that is too long to fit in a `sockaddr_un` structure, it will
`chdir()` to the parent directory of the requested socket pathname,
create the socket using a relative pathname, and then `chdir()` back.
This is not thread-safe.

Teach `unix_sockaddr_init()` to not allow calls to `chdir()` when this
flag is set.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/credential-cache.c
unix-socket.c
unix-socket.h