about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-05 23:27:55 +0000
committerEric Wong <e@80x24.org>2016-06-05 23:30:20 +0000
commit9f00d864e25e35ae6cb223b66a434965b14dbdca (patch)
treeb9ebae1d6b61f64be372fb486a37f16677c2663e /test
parent748a19f0d1bf3e10a79beb1ff5a2a8ddf5134a50 (diff)
downloadyahns-9f00d864e25e35ae6cb223b66a434965b14dbdca.tar.gz
On ENAMETOOLONG and perhaps other system errors which we can do
nothing about, we should not spew a giant backtrace which could
be used as an easy DoS vector.
Diffstat (limited to 'test')
-rw-r--r--test/test_extras_try_gzip_static.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_extras_try_gzip_static.rb b/test/test_extras_try_gzip_static.rb
index c6c8cef..4d20b5a 100644
--- a/test/test_extras_try_gzip_static.rb
+++ b/test/test_extras_try_gzip_static.rb
@@ -34,6 +34,18 @@ class TestExtrasTryGzipStatic < Testcase
       end
     end
 
+    Net::HTTP.start(host, port) do |http|
+      uri = "/COPYING/foo" + ('-' * 4096)
+      begin
+        res = http.request(Net::HTTP::Get.new(uri))
+      end while res.code.to_i == 414 && uri.chop!
+      res = http.request(Net::HTTP::Get.new("/COPYING/foo"))
+      assert_equal 404, res.code.to_i
+      lines = File.readlines(err.path)
+      File.truncate(err.path, 0)
+      assert_operator lines.size, :<, 3, lines.map! { |s| s[0,64] }.inspect
+    end
+
     begin # setup
       gpl = "#{tmpdir}/COPYING"
       gplgz = "#{tmpdir}/COPYING.gz"