about summary refs log tree commit homepage
path: root/lib/dtas
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-04-26 07:04:14 +0000
committerEric Wong <e@80x24.org>2024-05-07 08:52:59 +0000
commitb7e6406f79a1b27e50997e02ef6985ae0a33b14b (patch)
treee1cf505863f0eca68643ab37683aacc2b90cbe78 /lib/dtas
parent1deaad83499ad73df20a64a6a859c2d0dded1e0f (diff)
downloaddtas-b7e6406f79a1b27e50997e02ef6985ae0a33b14b.tar.gz
soxi or ffprobe may infinite loop on bad files, so be sure to
let these processes timeout properly.
Diffstat (limited to 'lib/dtas')
-rw-r--r--lib/dtas/source/av_ff_common.rb2
-rw-r--r--lib/dtas/source/sox.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb
index c600c48..7f197e0 100644
--- a/lib/dtas/source/av_ff_common.rb
+++ b/lib/dtas/source/av_ff_common.rb
@@ -92,7 +92,7 @@ module DTAS::Source::AvFfCommon # :nodoc:
 
       err = "".b
       begin
-        s = qx(@env, cmd, err_str: err, no_raise: true)
+        s = qx(@env, cmd, err_str: err, no_raise: true, rlimit_cpu: [ 1, 2 ])
       rescue Errno::ENOENT # avprobe/ffprobe not installed
         return false
       end
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index c03477e..365c7b6 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -39,7 +39,8 @@ class DTAS::Source::Sox # :nodoc:
   def mcache_lookup(infile)
     (@mcache ||= DTAS::Mcache.new).lookup(infile) do |input, dst|
       err = ''.b
-      out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true)
+      out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true,
+                rlimit_cpu: [ 1, 2 ])
       return soxi_failed(infile, out) if Process::Status === out
       return soxi_failed(infile, err) if err =~ /soxi FAIL formats:/
       out =~ /^Duration\s*:[^=]*= (\d+) samples /n