Merge pull request #21861 from rogday:21852_fix

Add assert to address tf simplifier security concerns
pull/21873/head
OpenCV Pushbot 3 years ago committed by GitHub
commit 9aff01c9a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/dnn/src/tensorflow/tf_graph_simplifier.cpp
  2. 7
      modules/dnn/test/test_tf_importer.cpp

@ -1035,7 +1035,7 @@ void sortByExecutionOrder(tensorflow::GraphDef& net)
nodesToAdd.pop_back(); nodesToAdd.pop_back();
permIds.push_back(nodeToAdd); permIds.push_back(nodeToAdd);
CV_Assert(nodeToAdd < edges.size());
for (int i = 0; i < edges[nodeToAdd].size(); ++i) for (int i = 0; i < edges[nodeToAdd].size(); ++i)
{ {
int consumerId = edges[nodeToAdd][i]; int consumerId = edges[nodeToAdd][i];

@ -1571,6 +1571,13 @@ TEST_P(Test_TensorFlow_layers, tf2_permute_nhwc_ncwh)
runTensorFlowNet("tf2_permute_nhwc_ncwh"); runTensorFlowNet("tf2_permute_nhwc_ncwh");
} }
// issue #21852
TEST_P(Test_TensorFlow_layers, tf_graph_simplifier_buffer_overflow)
{
// This just shouldn't segfault, otherwise it's fine
EXPECT_ANY_THROW(readNetFromTensorflow(path("tf_graph_simplifier_buffer_overflow_net.pb")));
}
TEST_P(Test_TensorFlow_layers, squeeze) TEST_P(Test_TensorFlow_layers, squeeze)
{ {
#if defined(INF_ENGINE_RELEASE) #if defined(INF_ENGINE_RELEASE)

Loading…
Cancel
Save