Skip to content

Commit

Permalink
Check sequence lengths when deserializing [10336] (#98)
Browse files Browse the repository at this point in the history
* Refs 10331. Tests refactor including check for wrong sequence length.

Signed-off-by: Miguel Company <[email protected]>

* Refs 10331. Check sequence length on deserialization.

Signed-off-by: Miguel Company <[email protected]>

* Refs 10331. Uncrustify.

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany authored Jan 26, 2021
1 parent 7afdcc0 commit 3107acc
Show file tree
Hide file tree
Showing 2 changed files with 628 additions and 3,177 deletions.
13 changes: 13 additions & 0 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,19 @@ class Cdr_DllAPI Cdr

*this >> seqLength;

if (seqLength == 0)
{
vector_t.clear();
return *this;
}

if ((m_lastPosition - m_currentPosition) < seqLength)
{
setState(state_before_error);
throw eprosima::fastcdr::exception::NotEnoughMemoryException(
eprosima::fastcdr::exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}

try
{
vector_t.resize(seqLength);
Expand Down
Loading

0 comments on commit 3107acc

Please sign in to comment.