Validate that strings in table are null terminated

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
This commit is contained in:
Alan Jowett 2022-06-10 18:47:10 -06:00 committed by Serge Lamikhov-Center
parent 2879ee62a2
commit f1c7d420e4

View File

@ -46,7 +46,11 @@ template <class S> class string_section_accessor_template
if ( index < string_section->get_size() ) {
const char* data = string_section->get_data();
if ( nullptr != data ) {
return data + index;
size_t string_length = strnlen(
data + index, string_section->get_size() - index );
if ( string_length <
( string_section->get_size() - index ) )
return data + index;
}
}
}