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:
Omkar Jadhav 2020-11-03 22:06:02 +05:30 committed by GitHub
parent 17428a8fbf
commit 72b81badad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View file

@ -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);