Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libpff/libpff_local_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ int libpff_local_descriptors_get_leaf_node_from_node_by_identifier(
{
return( 0 );
}
result = 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is used twice - just above, it's the return value of a submethod, but then it's also used later to represent the return value of this method itself. In between, we should make sure to reset it so that the first value doesn't accidentally get used for the second... this method is searching for a matching node and a value of 0 means no such node was found, so it's an appropriate default.

if( offsets_index_value == NULL )
{
libcerror_error_set(
Expand Down
79 changes: 30 additions & 49 deletions libpff/libpff_name_to_id_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,41 +365,34 @@ int libpff_name_to_id_map_read(

goto on_error;
}
if( name_to_id_map_entries_data == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: missing name to id map entries data.",
function );

goto on_error;
}
if( ( name_to_id_map_entries_data_size == 0 )
|| ( name_to_id_map_entries_data_size > (size_t) SSIZE_MAX ) )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
"%s: invalid name to id map entries data size value out of bounds.",
function );

goto on_error;
}
if( ( name_to_id_map_entries_data_size % 8 ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
"%s: unsupported name to id map entries size.",
function );

goto on_error;
}
number_of_name_to_id_map_entries = (uint32_t) ( name_to_id_map_entries_data_size / 8 );
if( name_to_id_map_entries_data == NULL || name_to_id_map_entries_data_size == 0)
{
number_of_name_to_id_map_entries = 0;
} else {
if(( name_to_id_map_entries_data_size > (size_t) SSIZE_MAX ) )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
"%s: invalid name to id map entries data size value out of bounds.",
function );

goto on_error;
}
if( ( name_to_id_map_entries_data_size % 8 ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
"%s: unsupported name to id map entries size.",
function );

goto on_error;
}
number_of_name_to_id_map_entries = (uint32_t) ( name_to_id_map_entries_data_size / 8 );
}

if( libpff_table_get_record_entry_by_type(
item_values->table,
Expand Down Expand Up @@ -452,19 +445,7 @@ int libpff_name_to_id_map_read(

goto on_error;
}
if( name_to_id_map_class_identifiers_data == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: missing name to id map class identifiers data.",
function );

goto on_error;
}
if( ( name_to_id_map_class_identifiers_data_size == 0 )
|| ( name_to_id_map_class_identifiers_data_size > (size64_t) SSIZE_MAX ) )
if( (name_to_id_map_class_identifiers_data_size > (size64_t) SSIZE_MAX ) )
{
libcerror_error_set(
error,
Expand Down Expand Up @@ -667,7 +648,7 @@ int libpff_name_to_id_map_entry_read(

return( -1 );
}
if( ( name_to_id_map_class_identifiers_data_size < 16 )
if( ( name_to_id_map_class_identifiers_data_size < 0 )
|| ( name_to_id_map_class_identifiers_data_size > (size_t) SSIZE_MAX ) )
{
libcerror_error_set(
Expand Down