mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Add failure test cases from zlib's inflate test suite
Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
committed by
Vinnie Falco
parent
7dbb3bd417
commit
84bf4c5362
@@ -362,6 +362,57 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testInflateErrors()
|
||||||
|
{
|
||||||
|
|
||||||
|
auto check =
|
||||||
|
[](std::initializer_list<std::uint8_t> const& in,
|
||||||
|
error_code expected)
|
||||||
|
{
|
||||||
|
std::string out(1024, 0);
|
||||||
|
z_params zs;
|
||||||
|
zs.next_in = &*in.begin();
|
||||||
|
zs.next_out = &out[0];
|
||||||
|
zs.avail_in = in.size();
|
||||||
|
zs.avail_out = out.size();
|
||||||
|
inflate_stream is;
|
||||||
|
is.reset(15);
|
||||||
|
boost::system::error_code ec;
|
||||||
|
is.write(zs,Flush::sync, ec);
|
||||||
|
BEAST_EXPECT(ec == expected);
|
||||||
|
};
|
||||||
|
check({0x00, 0x00, 0x00, 0x00, 0x00},
|
||||||
|
error::invalid_stored_length);
|
||||||
|
check({0x03, 0x00},
|
||||||
|
error::end_of_stream);
|
||||||
|
check({0x06},
|
||||||
|
error::invalid_block_type);
|
||||||
|
check({0xfc, 0x00, 0x00},
|
||||||
|
error::too_many_symbols);
|
||||||
|
check({0x04, 0x00, 0xfe, 0xff},
|
||||||
|
error::incomplete_length_set);
|
||||||
|
check({0x04, 0x00, 0x24, 0x49, 0x00},
|
||||||
|
error::invalid_bit_length_repeat);
|
||||||
|
check({0x04, 0x00, 0x24, 0xe9, 0xff, 0xff},
|
||||||
|
error::invalid_bit_length_repeat);
|
||||||
|
check({0x04, 0x00, 0x24, 0xe9, 0xff, 0x6d},
|
||||||
|
error::missing_eob);
|
||||||
|
check({0x04, 0x80, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24,
|
||||||
|
0x71, 0xff, 0xff, 0x93, 0x11, 0x00},
|
||||||
|
error::over_subscribed_length);
|
||||||
|
check({0x04, 0x80, 0x49, 0x92, 0x24, 0x0f, 0xb4, 0xff,
|
||||||
|
0xff, 0xc3, 0x84},
|
||||||
|
error::incomplete_length_set);
|
||||||
|
check({0x04, 0xc0, 0x81, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x20, 0x7f, 0xeb, 0x0b, 0x00, 0x00},
|
||||||
|
error::invalid_literal_length);
|
||||||
|
check({0x02, 0x7e, 0xff, 0xff},
|
||||||
|
error::invalid_distance_code);
|
||||||
|
check({0x0c, 0xc0, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x90, 0xff, 0x6b, 0x04, 0x00},
|
||||||
|
error::invalid_distance);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
@@ -369,6 +420,7 @@ public:
|
|||||||
"sizeof(inflate_stream) == " <<
|
"sizeof(inflate_stream) == " <<
|
||||||
sizeof(inflate_stream) << std::endl;
|
sizeof(inflate_stream) << std::endl;
|
||||||
testInflate();
|
testInflate();
|
||||||
|
testInflateErrors();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user