Merge pull request #15868 from alalek:issue_15857

This commit is contained in:
Alexander Alekhin 2019-11-07 14:21:35 +00:00
commit 5dd3e6052e
2 changed files with 12 additions and 2 deletions

View File

@ -578,10 +578,14 @@ public:
sz = (int)(ptr - beg);
if( sz > 0 )
{
if (i + sz >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("string is too long");
memcpy(buf + i, beg, sz);
i += sz;
}
ptr++;
if (i + 1 >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("string is too long");
switch ( *ptr )
{
case '\\':
@ -605,6 +609,8 @@ public:
sz = (int)(ptr - beg);
if( sz > 0 )
{
if (i + sz >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("string is too long");
memcpy(buf + i, beg, sz);
i += sz;
}
@ -620,6 +626,8 @@ public:
sz = (int)(ptr - beg);
if( sz > 0 )
{
if (i + sz >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("string is too long");
memcpy(buf + i, beg, sz);
i += sz;
}

View File

@ -627,6 +627,8 @@ public:
c = '\"';
else
{
if (len + 2 + i >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("string is too long");
memcpy( strbuf + i, ptr-1, len + 2 );
i += len + 2;
}
@ -635,9 +637,9 @@ public:
CV_PERSISTENCE_CHECK_END_OF_BUFFER_BUG_CPP();
}
}
if (i + 1 >= CV_FS_MAX_LEN)
CV_PARSE_ERROR_CPP("Too long string literal");
strbuf[i++] = c;
if( i >= CV_FS_MAX_LEN )
CV_PARSE_ERROR_CPP( "Too long string literal" );
}
elem->setValue(FileNode::STRING, strbuf, i);
}