Skip to content

Commit

Permalink
sanity check string vectors on read
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored and cary-ilm committed Aug 9, 2020
1 parent 0d13c74 commit fcaa169
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions OpenEXR/IlmImf/ImfStringVectorAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ StringVectorAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os
for (int i = 0; i < size; i++)
{
int strSize = _value[i].size();

Xdr::write <StreamIO> (os, strSize);
Xdr::write <StreamIO> (os, &_value[i][0], strSize);
}
Expand All @@ -82,6 +83,13 @@ StringVectorAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &i
Xdr::read <StreamIO> (is, strSize);
read += Xdr::size<int>();

// check there is enough space remaining in attribute to
// contain claimed string length
if( strSize < 0 || strSize+read > size)
{
throw IEX_NAMESPACE::InputExc("Invalid size field reading stringvector attribute");
}

std::string str;
str.resize (strSize);

Expand Down

0 comments on commit fcaa169

Please sign in to comment.