fix race condition allowing attackers to access destination file
authorW. Felix Handte <w@felixhandte.com>
Thu, 18 Feb 2021 08:52:53 +0000 (08:52 +0000)
committerÉtienne Mollier <etienne.mollier@mailoo.org>
Thu, 18 Feb 2021 08:52:53 +0000 (08:52 +0000)
commit16c9a698c24437e6ecc02691c9a82c788f0c9d12
tree1abfafff294d9daa21b439d0c6b7f5a5e9ce2c30
parent0f20d5e049b9dc5dbff9004933773d1b1f409fbb
fix race condition allowing attackers to access destination file

Origin: upstream
Bug: https://github.com/facebook/zstd/issues/2491
Bug-Debian: https://github.com/facebook/zstd/issues/2491
Applied-Upstream: commit:a774c5797399040af62db21d8a9b9769e005430e
Reviewed-by: Étienne Mollier <etienne.mollier@mailoo.org>
Last-Update: 2021-02-18

This commit addresses https://github.com/facebook/zstd/issues/2491.

Note that a downside of this solution is that it is global: `umask()` affects
all file creation calls in the process. I believe this is safe since
`fileio.c` functions should only ever be used in the zstd binary, and these
are (almost) the only files ever created by zstd, and AIUI they're only
created in a single thread. So we can get away with messing with global state.

Note that this doesn't change the permissions of files created by `dibio.c`.
I'm not sure what those should be...
Last-Update: 2021-02-18
Gbp-Pq: Name 0018-fix-file-permissions-on-compression.patch
programs/fileio.c
programs/util.c
programs/util.h