diff options
author | Eric Wong <e@80x24.org> | 2019-12-15 02:20:07 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-15 02:20:07 +0000 |
commit | 041138d280a49f6ab122c4299503b9fc9d671643 (patch) | |
tree | 19403cdb6ba0d153a33d67eb17b004fa4f3907a5 /lib/unicorn/tmpio.rb | |
parent | 5e3d05997769dd270123b9c2479938704de078de (diff) | |
parent | 024f7a8c8c780b6eae4f952dd6ef86dca8036cb6 (diff) | |
download | unicorn-041138d280a49f6ab122c4299503b9fc9d671643.tar.gz |
* origin/ts/tmpio: tmpio: workaround File#path being tainted on unlink
Diffstat (limited to 'lib/unicorn/tmpio.rb')
-rw-r--r-- | lib/unicorn/tmpio.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/unicorn/tmpio.rb b/lib/unicorn/tmpio.rb index db88ed3..0bbf6ec 100644 --- a/lib/unicorn/tmpio.rb +++ b/lib/unicorn/tmpio.rb @@ -11,12 +11,18 @@ class Unicorn::TmpIO < File # immediately, switched to binary mode, and userspace output # buffering is disabled def self.new + path = nil + + # workaround File#path being tainted: + # https://bugs.ruby-lang.org/issues/14485 fp = begin - super("#{Dir::tmpdir}/#{rand}", RDWR|CREAT|EXCL, 0600) + path = "#{Dir::tmpdir}/#{rand}" + super(path, RDWR|CREAT|EXCL, 0600) rescue Errno::EEXIST retry end - unlink(fp.path) + + unlink(path) fp.binmode fp.sync = true fp |