Skip to content

Commit 55eeab6

Browse files
committed
Fuzz the framer.
1 parent 3cbfdd8 commit 55eeab6

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

fuzz/framer/bake.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Run the fuzz test.
3+
def run
4+
system("AFL_SKIP_BIN_CHECK=1 afl-fuzz -i input/ -o output/ -t 1000 -m 1000 -- ruby script.rb")
5+
end
6+
7+
def generate
8+
require_relative '../../lib/protocol/http2/framer'
9+
10+
framer = Protocol::HTTP2::Framer.new($stdout)
11+
12+
frame = Protocol::HTTP2::DataFrame.new
13+
frame.pack("Hello World")
14+
15+
framer.write_frame(frame)
16+
end

fuzz/framer/input/data.txt

20 Bytes
Binary file not shown.

fuzz/framer/script.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'socket'
4+
require_relative '../../lib/protocol/http2/framer'
5+
6+
def test
7+
framer = Protocol::HTTP2::Framer.new($stdin)
8+
9+
while frame = framer.read_frame
10+
pp frame
11+
end
12+
rescue EOFError
13+
# Ignore.
14+
end
15+
16+
if ENV["_"] =~ /afl/
17+
require 'kisaten'
18+
19+
Kisaten.crash_at [Exception], [EOFError, Protocol::HTTP2::FrameSizeError], Signal.list['USR1']
20+
21+
while Kisaten.loop 10_000
22+
test
23+
end
24+
else
25+
test
26+
end

0 commit comments

Comments
 (0)