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
4 changes: 3 additions & 1 deletion libfsapfs/libfsapfs_compressed_data_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int libfsapfs_compressed_data_handle_initialize(
}
if( ( compression_method != LIBFSAPFS_COMPRESSION_METHOD_DEFLATE )
&& ( compression_method != LIBFSAPFS_COMPRESSION_METHOD_LZVN )
&& ( compression_method != LIBFSAPFS_COMPRESSION_METHOD_RAW )
&& ( compression_method != LIBFSAPFS_COMPRESSION_METHOD_UNKNOWN5 ) )
{
libcerror_error_set(
Expand Down Expand Up @@ -459,7 +460,8 @@ int libfsapfs_compressed_data_handle_get_compressed_block_offsets(
compressed_descriptors_offset += 4;
compressed_block_descriptor_size = 8;
}
else if( data_handle->compression_method == LIBFSAPFS_COMPRESSION_METHOD_LZVN )
else if( ( data_handle->compression_method == LIBFSAPFS_COMPRESSION_METHOD_LZVN )
|| ( data_handle->compression_method == LIBFSAPFS_COMPRESSION_METHOD_RAW ) )
{
segment_data_offset = 0;

Expand Down
69 changes: 67 additions & 2 deletions libfsapfs/libfsapfs_compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int libfsapfs_decompress_data(
error,
LIBCERROR_ERROR_DOMAIN_MEMORY,
LIBCERROR_MEMORY_ERROR_COPY_FAILED,
"%s: unable to compressed to uncompressed data.",
"%s: unable to copy compressed to uncompressed data.",
function );

return( -1 );
Expand Down Expand Up @@ -274,6 +274,71 @@ int libfsapfs_decompress_data(
#endif /* ( defined( HAVE_ZLIB ) && defined( HAVE_ZLIB_UNCOMPRESS ) ) || defined( ZLIB_DLL ) */
}
}
else if( compression_method == LIBFSAPFS_COMPRESSION_METHOD_RAW )
{
if( ( compressed_data_size < 1 )
|| ( compressed_data[ 0 ] != 0xcc ) )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
"%s: invalid raw compressed data - unsupported marker byte.",
function );

return( -1 );
}
if( compressed_data_size > (size_t) SSIZE_MAX )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
"%s: invalid compressed data size value exceeds maximum.",
function );

return( -1 );
}
if( *uncompressed_data_size > (size_t) SSIZE_MAX )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
"%s: invalid uncompressed data size value exceeds maximum.",
function );

return( -1 );
}
if( ( compressed_data_size - 1 ) > *uncompressed_data_size )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
"%s: compressed data size value exceeds uncompressed data size.",
function );

return( -1 );
}
*uncompressed_data_size = compressed_data_size - 1;

if( memory_copy(
uncompressed_data,
&( compressed_data[ 1 ] ),
*uncompressed_data_size ) == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_MEMORY,
LIBCERROR_MEMORY_ERROR_COPY_FAILED,
"%s: unable to copy compressed to uncompressed data.",
function );

return( -1 );
}
result = 1;
}
#ifdef TODO
/* TODO need sample data */
else if( compression_method == LIBFSAPFS_COMPRESSION_METHOD_LZFSE )
Expand Down Expand Up @@ -347,7 +412,7 @@ int libfsapfs_decompress_data(
error,
LIBCERROR_ERROR_DOMAIN_MEMORY,
LIBCERROR_MEMORY_ERROR_COPY_FAILED,
"%s: unable to compressed to uncompressed data.",
"%s: unable to copy compressed to uncompressed data.",
function );

return( -1 );
Expand Down
1 change: 1 addition & 0 deletions libfsapfs/libfsapfs_definitions.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ enum LIBFSAPFS_COMPRESSION_METHODS
LIBFSAPFS_COMPRESSION_METHOD_DEFLATE = 1,
LIBFSAPFS_COMPRESSION_METHOD_LZFSE = 2,
LIBFSAPFS_COMPRESSION_METHOD_LZVN = 3,
LIBFSAPFS_COMPRESSION_METHOD_RAW = 4,

LIBFSAPFS_COMPRESSION_METHOD_UNKNOWN5 = 5
};
Expand Down
8 changes: 7 additions & 1 deletion libfsapfs/libfsapfs_file_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -4357,6 +4357,11 @@ int libfsapfs_internal_file_entry_get_data_stream(
compression_method = LIBFSAPFS_COMPRESSION_METHOD_LZVN;
break;

case 9:
case 10:
compression_method = LIBFSAPFS_COMPRESSION_METHOD_RAW;
break;

case 11:
case 12:
compression_method = LIBFSAPFS_COMPRESSION_METHOD_LZFSE;
Expand All @@ -4374,7 +4379,8 @@ int libfsapfs_internal_file_entry_get_data_stream(
goto on_error;
}
if( ( internal_file_entry->compressed_data_header->compression_method == 4 )
|| ( internal_file_entry->compressed_data_header->compression_method == 8 ) )
|| ( internal_file_entry->compressed_data_header->compression_method == 8 )
|| ( internal_file_entry->compressed_data_header->compression_method == 10 ) )
{
if( libfsapfs_attributes_get_data_stream(
internal_file_entry->resource_fork_attribute_values,
Expand Down
Loading
Loading