summaryrefslogtreecommitdiff
path: root/tests/t0111-filter.sh
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2018-06-20 05:29:14 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-27 16:13:03 +0000
commitb31e99887b17f513289fb11227b2484504e85b6c (patch)
treefd4b868e415db4de0577495eabf48e6bf814d408 /tests/t0111-filter.sh
parent255b78ff5291cef79978b025c9872f801de89e23 (diff)
downloadcgit-b31e99887b17f513289fb11227b2484504e85b6c.tar
cgit-b31e99887b17f513289fb11227b2484504e85b6c.tar.gz
cgit-b31e99887b17f513289fb11227b2484504e85b6c.zip
cache: close race window when unlocking slots
We use POSIX advisory record locks to control access to cache slots, but these have an unhelpful behaviour in that they are released when any file descriptor referencing the file is closed by this process. Mostly this is okay, since we know we won't be opening the lock file anywhere else, but there is one place that it does matter: when we restore stdout we dup2() over a file descriptor referring to the file, thus closing that descriptor. Since we restore stdout before unlocking the slot, this creates a window during which the slot content can be overwritten. The fix is reasonably straightforward: simply restore stdout after unlocking the slot, but the diff is a bit bigger because this requires us to move the temporary stdout FD into struct cache_slot. Signed-off-by: John Keeping <john@keeping.me.uk> Reviewed-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'tests/t0111-filter.sh')
0 files changed, 0 insertions, 0 deletions