Skip to content

Commit

Permalink
Tests: avoid illegal dereference on errors in h2_headers.t.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluknet committed May 3, 2017
1 parent 9f53da6 commit 1e210ec
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions h2_headers.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Test::Nginx::HTTP2;
select STDERR; $| = 1;
select STDOUT; $| = 1;

my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(92)
my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(93)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
Expand Down Expand Up @@ -606,13 +606,14 @@ $sid = $s->new_stream({ path => '/continuation?h=' . 'x' x 2**13 });

$frames = $s->read(all => [{ sid => $sid, fin => 0x4 }]);
my @data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
my $data = $data[-1];
is(@{$data->{headers}{'x-longheader'}}, 3,
'response CONTINUATION - headers');
is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[0], 'x' x 2**13,
'response CONTINUATION - header 1');
is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[1], 'x' x 2**13,
'response CONTINUATION - header 2');
is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[2], 'x' x 2**13,
'response CONTINUATION - header 3');
@data = sort { $a <=> $b } map { $_->{length} } @data;
cmp_ok($data[-1], '<=', 2**14, 'response CONTINUATION - max frame size');
Expand All @@ -624,13 +625,14 @@ $sid = $s->new_stream({ path => '/continuation/204?h=' . 'x' x 2**13 });

$frames = $s->read(all => [{ sid => $sid, fin => 0x4 }]);
@data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
is(@{$data[-1]->{headers}{'x-longheader'}}, 3,
$data = $data[-1];
is(@{$data->{headers}{'x-longheader'}}, 3,
'no body CONTINUATION - headers');
is($data[-1]->{headers}{'x-longheader'}[0], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[0], 'x' x 2**13,
'no body CONTINUATION - header 1');
is($data[-1]->{headers}{'x-longheader'}[1], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[1], 'x' x 2**13,
'no body CONTINUATION - header 2');
is($data[-1]->{headers}{'x-longheader'}[2], 'x' x 2**13,
is($data->{headers}{'x-longheader'}[2], 'x' x 2**13,
'no body CONTINUATION - header 3');
@data = sort { $a <=> $b } map { $_->{length} } @data;
cmp_ok($data[-1], '<=', 2**14, 'no body CONTINUATION - max frame size');
Expand Down Expand Up @@ -674,12 +676,19 @@ $sid = $s->new_stream({ path => '/continuation?h=' . 'x' x 2**15 });
$frames = $s->read(all => [{ sid => $sid, fin => 0x4 }]);

@data = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
ok(@data, 'response header split');

SKIP: {
skip 'response header split failed', 2 unless @data;

my ($lengths) = sort { $b <=> $a } map { $_->{length} } @data;
cmp_ok($lengths, '<=', 16384, 'response header split - max size');

is(length join('', @{@$frames[-1]->{headers}->{'x-longheader'}}), 98304,
is(length join('', @{$data[-1]->{headers}->{'x-longheader'}}), 98304,
'response header split - headers');

}

# max_field_size - header field name

$s = Test::Nginx::HTTP2->new(port(8084));
Expand Down

0 comments on commit 1e210ec

Please sign in to comment.