mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
Fix issues reported by oss-fuzz (#729)
* Fix oss-fuzz issue #26529 * Add test for oss-fuzz issue #26598 * Fix oss-fuzz issue #26632 * Revert change and add new test cases
This commit is contained in:
parent
17428a8fbf
commit
72b81badad
2 changed files with 25 additions and 3 deletions
21
test/test.cc
21
test/test.cc
|
@ -1930,6 +1930,15 @@ TEST_F(ServerTest, GetStreamedWithRangeError) {
|
|||
EXPECT_EQ(416, res->status);
|
||||
}
|
||||
|
||||
//Tests long long overflow.
|
||||
TEST_F(ServerTest, GetRangeWithMaxLongLength) {
|
||||
auto res = cli_.Get("/with-range",{{"Range", "bytes=0-9223372036854775807"}});
|
||||
EXPECT_EQ(206, res->status);
|
||||
EXPECT_EQ("7", res->get_header_value("Content-Length"));
|
||||
EXPECT_EQ(true, res->has_header("Content-Range"));
|
||||
EXPECT_EQ(std::string("abcdefg"), res->body);
|
||||
}
|
||||
|
||||
TEST_F(ServerTest, GetStreamedWithRangeMultipart) {
|
||||
auto res =
|
||||
cli_.Get("/streamed-with-range", {{make_range_header({{1, 2}, {4, 5}})}});
|
||||
|
@ -2012,6 +2021,12 @@ TEST_F(ServerTest, GetWithRange4) {
|
|||
EXPECT_EQ(std::string("fg"), res->body);
|
||||
}
|
||||
|
||||
//TEST_F(ServerTest, GetWithRangeOffsetGreaterThanContent) {
|
||||
// auto res = cli_.Get("/with-range", {{make_range_header({{10000, 20000}})}});
|
||||
// ASSERT_TRUE(res);
|
||||
// EXPECT_EQ(416, res->status);
|
||||
//}
|
||||
|
||||
TEST_F(ServerTest, GetWithRangeMultipart) {
|
||||
auto res = cli_.Get("/with-range", {{make_range_header({{1, 2}, {4, 5}})}});
|
||||
ASSERT_TRUE(res);
|
||||
|
@ -2021,6 +2036,12 @@ TEST_F(ServerTest, GetWithRangeMultipart) {
|
|||
EXPECT_EQ(269, res->body.size());
|
||||
}
|
||||
|
||||
//TEST_F(ServerTest, GetWithRangeMultipartOffsetGreaterThanContent) {
|
||||
// auto res = cli_.Get("/with-range", {{make_range_header({{-1, 2}, {10000, 30000}})}});
|
||||
// ASSERT_TRUE(res);
|
||||
// EXPECT_EQ(416, res->status);
|
||||
//}
|
||||
|
||||
TEST_F(ServerTest, GetStreamedChunked) {
|
||||
auto res = cli_.Get("/streamed-chunked");
|
||||
ASSERT_TRUE(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue