Skip to content

Commit

Permalink
Changes to improve handling corrupt file entry extension values
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jun 23, 2018
1 parent 6b407b5 commit eeed871
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
36 changes: 36 additions & 0 deletions libfwsi/libfwsi_file_entry_extension_values.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ int libfwsi_file_entry_extension_values_read_data(

if( version >= 7 )
{
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= ( data_size - 18 ) )
{
return( 0 );
}
#if defined( HAVE_DEBUG_OUTPUT )
if( libcnotify_verbose != 0 )
{
Expand Down Expand Up @@ -345,6 +351,12 @@ int libfwsi_file_entry_extension_values_read_data(
#endif
data_offset += 8;
}
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= ( data_size - 2 ) )
{
return( 0 );
}
byte_stream_copy_to_uint16_little_endian(
&( data[ data_offset ] ),
long_string_size );
Expand All @@ -362,6 +374,12 @@ int libfwsi_file_entry_extension_values_read_data(

if( version >= 9 )
{
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= ( data_size - 4 ) )
{
return( 0 );
}
#if defined( HAVE_DEBUG_OUTPUT )
if( libcnotify_verbose != 0 )
{
Expand All @@ -378,6 +396,12 @@ int libfwsi_file_entry_extension_values_read_data(
}
if( version >= 8 )
{
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= ( data_size - 4 ) )
{
return( 0 );
}
#if defined( HAVE_DEBUG_OUTPUT )
if( libcnotify_verbose != 0 )
{
Expand All @@ -392,6 +416,12 @@ int libfwsi_file_entry_extension_values_read_data(
#endif
data_offset += 4;
}
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= data_size )
{
return( 0 );
}
/* Determine the long name size
*/
for( string_size = data_offset;
Expand Down Expand Up @@ -464,6 +494,12 @@ int libfwsi_file_entry_extension_values_read_data(

if( long_string_size > 0 )
{
/* Do not try to parse unsupported data sizes
*/
if( data_offset >= data_size )
{
return( 0 );
}
if( version >= 7 )
{
/* Determine the localized name size
Expand Down
10 changes: 5 additions & 5 deletions libfwsi/libfwsi_network_location_values.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ int libfwsi_network_location_values_read_data(
if( libcnotify_verbose != 0 )
{
libcnotify_printf(
"%s: unknown0\t\t\t\t: 0x%02" PRIx8 "\n",
"%s: unknown0\t\t\t: 0x%02" PRIx8 "\n",
function,
data[ 3 ] );

libcnotify_printf(
"%s: flags\t\t\t\t: 0x%02" PRIx8 "\n",
"%s: flags\t\t\t: 0x%02" PRIx8 "\n",
function,
flags );
}
Expand Down Expand Up @@ -288,7 +288,7 @@ int libfwsi_network_location_values_read_data(
{
if( libfwsi_debug_print_string_value(
function,
"network location\t\t\t",
"network location\t\t",
network_location_values->location,
network_location_values->location_size,
ascii_codepage,
Expand Down Expand Up @@ -432,7 +432,7 @@ int libfwsi_network_location_values_read_data(
{
if( libfwsi_debug_print_string_value(
function,
"network comments\t\t\t",
"network comments\t\t",
network_location_values->comments,
network_location_values->comments_size,
ascii_codepage,
Expand Down Expand Up @@ -461,7 +461,7 @@ int libfwsi_network_location_values_read_data(
value_16bit );

libcnotify_printf(
"%s: unknown1\t\t\t\t: 0x%04" PRIx16 "\n",
"%s: unknown1\t\t\t: 0x%04" PRIx16 "\n",
function,
value_16bit );
}
Expand Down

0 comments on commit eeed871

Please sign in to comment.