about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2010-10-05 15:45:16 -0700
committerEric Wong <e@yhbt.net>2010-10-05 15:53:29 -0700
commite085bb9600b190692beb5efc85656ebf127ae08c (patch)
treee8e54ec583fa85e73a421718d58bf079ec555f60 /test
parentb168cc894037620cab82fa82f3ab37a3aab81570 (diff)
downloadkgio-e085bb9600b190692beb5efc85656ebf127ae08c.tar.gz
Malicious clients may disconnect during big writes to cause
EPIPE and ECONNRESET exceptions.  Generating backtraces can be
expensive with Ruby, so mitigate the DoS vector by lowering the
cost of generating an exception.
Diffstat (limited to 'test')
-rw-r--r--test/lib_read_write.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/lib_read_write.rb b/test/lib_read_write.rb
index bb5ec42..146c222 100644
--- a/test/lib_read_write.rb
+++ b/test/lib_read_write.rb
@@ -38,16 +38,24 @@ module LibReadWriteTest
 
   def test_write_closed
     @rd.close
-    assert_raises(Errno::EPIPE, Errno::ECONNRESET) {
+    begin
       loop { @wr.kgio_write "HI" }
-    }
+    rescue Errno::EPIPE, Errno::ECONNRESET => e
+      assert_equal [], e.backtrace
+      return
+    end
+    assert false, "should never get here (line:#{__LINE__})"
   end
 
   def test_trywrite_closed
     @rd.close
-    assert_raises(Errno::EPIPE, Errno::ECONNRESET) {
+    begin
       loop { @wr.kgio_trywrite "HI" }
-    }
+    rescue Errno::EPIPE, Errno::ECONNRESET => e
+      assert_equal [], e.backtrace
+      return
+    end
+    assert false, "should never get here (line:#{__LINE__})"
   end
 
   def test_write_conv