Skip to content

Commit

Permalink
Sanity-check loop bounds in SHAPE_LINE_CHAIN::Parse
Browse files Browse the repository at this point in the history
Coverity CID: 128540
  • Loading branch information
Chris Pavlina committed May 12, 2016
1 parent e782e46 commit a488cb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion common/geometry/shape_line_chain.cpp
Expand Up @@ -570,6 +570,11 @@ bool SHAPE_LINE_CHAIN::Parse( std::stringstream& aStream )

m_points.clear();
aStream >> n_pts;

// Rough sanity check, just make sure the loop bounds aren't absolutely outlandish
if( n_pts < 0 || n_pts > aStream.str().size() )
return false;

aStream >> m_closed;

for( int i = 0; i < n_pts; i++ )
Expand All @@ -581,4 +586,4 @@ bool SHAPE_LINE_CHAIN::Parse( std::stringstream& aStream )
}

return true;
}
}

0 comments on commit a488cb0

Please sign in to comment.