about summary refs log tree commit homepage
path: root/lib/unicorn/tmpio.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-15 02:20:07 +0000
committerEric Wong <e@80x24.org>2019-12-15 02:20:07 +0000
commit041138d280a49f6ab122c4299503b9fc9d671643 (patch)
tree19403cdb6ba0d153a33d67eb17b004fa4f3907a5 /lib/unicorn/tmpio.rb
parent5e3d05997769dd270123b9c2479938704de078de (diff)
parent024f7a8c8c780b6eae4f952dd6ef86dca8036cb6 (diff)
downloadunicorn-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.rb10
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