protocol-http1 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of protocol-http1 might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22aa54b84d5e367d855540a30f40103e384c2bed44d023cb14fa0be4024455b
4
- data.tar.gz: ea92287d17970faf97174324907815798664be67316cd790af6fe7522263d586
3
+ metadata.gz: 28184b21d65b6cde9ee2985a6680ecbd01ce6e63a6d812cc440a13a6785de072
4
+ data.tar.gz: de2c9f93370098fe72637140523e428ce5dc170b06af494b4d0cd424c4ecd3d9
5
5
  SHA512:
6
- metadata.gz: f44d2e720314924e6b57c2f6e3e5f288ae8e4a5487d5730b9a343b959c0b28397594e8283e0180b70ebb5b75ccfab644b2bb609b0143bb2886c5d33d0b9dbdd5
7
- data.tar.gz: c6afa65e6541ba2c0d8186c495c29f2fd3549b4a8e17cd91c379c409c8251e4146e10d82fc9835c761c040c4c48ea47934736f94ed9ee90b23716e2ee98b6c5c
6
+ metadata.gz: d42abab0bbb5c5b95efdbba9caf23b64ab4cad2d63b7ecf37abb5269ba726d42592f9a2eac673a987e5a72c116cee8a07c7ce8a929bd1fc7bc6ab7bab25b5be8
7
+ data.tar.gz: fdadc58aa32cbcd37672eda928fdc207f0180483266ae6813e726692b2c32858566439d1a4a7d1e48a7eebf7779539d39f973e1ff92cda0a87ba07fa884c2c26
@@ -0,0 +1,5 @@
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
@@ -0,0 +1,6 @@
1
+ POST /upload HTTP/1.1
2
+ Host: example.com
3
+ Accept: */*
4
+ Content-Length: 10
5
+
6
+ 0123456789
@@ -0,0 +1,2 @@
1
+ GET / HTTP/1.1
2
+
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'socket'
4
+ require_relative '../../lib/protocol/http1'
5
+
6
+ def test
7
+ # input, output = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)
8
+
9
+ server = Protocol::HTTP1::Connection.new($stdin)
10
+
11
+ # input.write($stdin.read)
12
+ # input.close
13
+
14
+ begin
15
+ host, method, path, version, headers, body = server.read_request
16
+
17
+ body = server.read_request_body(method, headers)
18
+ rescue Protocol::HTTP1::InvalidRequest
19
+ # Ignore.
20
+ end
21
+ end
22
+
23
+ if ENV["_"] =~ /afl/
24
+ require 'kisaten'
25
+ Kisaten.crash_at [], [], Signal.list['USR1']
26
+
27
+ while Kisaten.loop 10000
28
+ test
29
+ end
30
+ else
31
+ test
32
+ end
@@ -281,14 +281,17 @@ module Protocol
281
281
 
282
282
  def write_fixed_length_body(body, length, head)
283
283
  @stream.write("content-length: #{length}\r\n\r\n")
284
- @stream.flush
285
284
 
286
285
  if head
286
+ @stream.flush
287
+
287
288
  body.close
288
289
 
289
290
  return
290
291
  end
291
292
 
293
+ @stream.flush unless body.ready?
294
+
292
295
  chunk_length = 0
293
296
  body.each do |chunk|
294
297
  chunk_length += chunk.bytesize
@@ -309,21 +312,25 @@ module Protocol
309
312
 
310
313
  def write_chunked_body(body, head, trailers = nil)
311
314
  @stream.write("transfer-encoding: chunked\r\n\r\n")
312
- @stream.flush
313
315
 
314
316
  if head
317
+ @stream.flush
318
+
315
319
  body.close
316
320
 
317
321
  return
318
322
  end
319
323
 
324
+ @stream.flush unless body.ready?
325
+
320
326
  body.each do |chunk|
321
327
  next if chunk.size == 0
322
328
 
323
329
  @stream.write("#{chunk.bytesize.to_s(16).upcase}\r\n")
324
330
  @stream.write(chunk)
325
331
  @stream.write(CRLF)
326
- @stream.flush
332
+
333
+ @stream.flush unless body.ready?
327
334
  end
328
335
 
329
336
  if trailers
@@ -342,14 +349,15 @@ module Protocol
342
349
  @persistent = false
343
350
 
344
351
  @stream.write("\r\n")
345
- @stream.flush
352
+ @stream.flush unless body.ready?
346
353
 
347
354
  if head
348
355
  body.close
349
356
  else
350
357
  body.each do |chunk|
351
358
  @stream.write(chunk)
352
- @stream.flush
359
+
360
+ @stream.flush unless body.ready?
353
361
  end
354
362
  end
355
363
 
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Protocol
24
24
  module HTTP1
25
- VERSION = "0.12.0"
25
+ VERSION = "0.13.0"
26
26
  end
27
27
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "protocol-http", "~> 0.18"
23
+ spec.add_dependency "protocol-http", "~> 0.19"
24
24
 
25
25
  spec.add_development_dependency "covered"
26
26
  spec.add_development_dependency "bundler"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-08 00:00:00.000000000 Z
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: protocol-http
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.18'
26
+ version: '0.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: covered
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,10 @@ files:
122
122
  - Gemfile
123
123
  - README.md
124
124
  - examples/http1/request.rb
125
+ - fuzz/request/bake.rb
126
+ - fuzz/request/input/body.txt
127
+ - fuzz/request/input/simple.txt
128
+ - fuzz/request/script.rb
125
129
  - lib/protocol/http1.rb
126
130
  - lib/protocol/http1/body/chunked.rb
127
131
  - lib/protocol/http1/body/fixed.rb