Test for CVE-2017-5950
This commit is contained in:
parent
9b8f35093e
commit
d8934a4358
@ -1,9 +1,11 @@
|
|||||||
#include "yaml-cpp/parser.h"
|
#include "yaml-cpp/parser.h"
|
||||||
|
#include "yaml-cpp/exceptions.h"
|
||||||
#include "mock_event_handler.h"
|
#include "mock_event_handler.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
using YAML::Parser;
|
using YAML::Parser;
|
||||||
using YAML::MockEventHandler;
|
using YAML::MockEventHandler;
|
||||||
|
using ::testing::NiceMock;
|
||||||
using ::testing::StrictMock;
|
using ::testing::StrictMock;
|
||||||
|
|
||||||
TEST(ParserTest, Empty) {
|
TEST(ParserTest, Empty) {
|
||||||
@ -14,3 +16,14 @@ TEST(ParserTest, Empty) {
|
|||||||
StrictMock<MockEventHandler> handler;
|
StrictMock<MockEventHandler> handler;
|
||||||
EXPECT_FALSE(parser.HandleNextDocument(handler));
|
EXPECT_FALSE(parser.HandleNextDocument(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ParserTest, CVE_2017_5950) {
|
||||||
|
std::string excessive_recursion;
|
||||||
|
for (auto i = 0; i != 16384; ++i)
|
||||||
|
excessive_recursion.push_back('[');
|
||||||
|
std::istringstream input{excessive_recursion};
|
||||||
|
Parser parser{input};
|
||||||
|
|
||||||
|
NiceMock<MockEventHandler> handler;
|
||||||
|
EXPECT_THROW(parser.HandleNextDocument(handler), YAML::ParserException);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user