Skip to content

Commit

Permalink
Changed ltree path segment separator
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jul 5, 2023
1 parent c19ab6a commit dd87dd6
Show file tree
Hide file tree
Showing 18 changed files with 427 additions and 107 deletions.
6 changes: 3 additions & 3 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
TODO
* change ltree path segment separator
* handle path segment separator in ewfinfo -F
* change ltree to preserve UTF-16, limit file name functions to support chars beyond Unicode
* change ltree to read directory entries on demand
* calculate the MD5 while incremental ltree read, use line reader instead?

* escape unpaired surrogates in bodyfile

* info_handle: move dfxml functions to seperate file
* clean up libewf_chunk_group_correct_v1

Expand Down
12 changes: 12 additions & 0 deletions documentation/Expert Witness Compression Format (EWF).asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,18 @@ The ltree data string consists of an UTF-16 little-endian encoded string without
byte order mark. The ltree data is not strict UTF-16 since it allows for unpaired
surrogates, such as "U+d800" and "U+dc00".

Other observed characteristics where the names in the ltree deviate from
the original source:

* [U+0001-U+0008] were converted to U+00ba
* [U+0009, U+000a] were stripped
* [U+000b, U+000c] were converted to U+0020
* U+000d was converted to U+0002
* U+00ba remained the same

Note that this behavior could be related to Encase as well and might not be
specific for EWF-L01.

The ltree data string contains the following information:

[cols="1,1,5",options="header"]
Expand Down
78 changes: 59 additions & 19 deletions ewftools/ewfinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void usage_fprint(
"Compression Format).\n\n" );

fprintf( stream, "Usage: ewfinfo [ -A codepage ] [ -B bodyfile ] [ -d date_format ]\n"
" [ -f format ] [ -F path ] [ -ehHimvVx ] ewf_files\n\n" );
" [ -f format ] [ -F path ] [ -s separator ] [ -ehHimvVx ]\n"
" ewf_files\n\n" );

fprintf( stream, "\tewf_files: the first or the entire set of EWF segment files\n\n" );

Expand All @@ -97,6 +98,7 @@ void usage_fprint(
fprintf( stream, "\t-H: shows the logical files hierarchy\n" );
fprintf( stream, "\t-i: only show EWF acquiry information\n" );
fprintf( stream, "\t-m: only show EWF media information\n" );
fprintf( stream, "\t-s: path segment separator, options: / (default), \\\n" );
fprintf( stream, "\t-v: verbose output to stderr\n" );
fprintf( stream, "\t-V: print version\n" );
}
Expand All @@ -107,7 +109,7 @@ void ewfinfo_signal_handler(
ewftools_signal_t signal EWFTOOLS_ATTRIBUTE_UNUSED )
{
libcerror_error_t *error = NULL;
static char *function = "ewfinfo_signal_handler";
static char *function = "ewfinfo_signal_handler";

EWFTOOLS_UNREFERENCED_PARAMETER( signal )

Expand Down Expand Up @@ -155,24 +157,25 @@ int main( int argc, char * const argv[] )
struct rlimit limit_data;
#endif

system_character_t * const *source_filenames = NULL;
libcerror_error_t *error = NULL;
system_character_t *option_bodyfile = NULL;
system_character_t *option_date_format = NULL;
system_character_t *option_file_entry = NULL;
system_character_t *option_header_codepage = NULL;
system_character_t *option_output_format = NULL;
system_character_t *program = _SYSTEM_STRING( "ewfinfo" );
system_integer_t option = 0;
uint8_t verbose = 0;
int number_of_filenames = 0;
int option_mode = EWFINFO_MODE_IMAGE;
int print_header = 1;
int result = 0;
char info_option = 'a';
system_character_t * const *source_filenames = NULL;
libcerror_error_t *error = NULL;
system_character_t *option_bodyfile = NULL;
system_character_t *option_date_format = NULL;
system_character_t *option_file_entry = NULL;
system_character_t *option_header_codepage = NULL;
system_character_t *option_output_format = NULL;
system_character_t *option_path_segment_separator = NULL;
system_character_t *program = _SYSTEM_STRING( "ewfinfo" );
system_integer_t option = 0;
uint8_t verbose = 0;
int number_of_filenames = 0;
int option_mode = EWFINFO_MODE_IMAGE;
int print_header = 1;
int result = 0;
char info_option = 'a';

#if !defined( HAVE_GLOB_H )
ewftools_glob_t *glob = NULL;
ewftools_glob_t *glob = NULL;
#endif

libcnotify_stream_set(
Expand Down Expand Up @@ -208,7 +211,7 @@ int main( int argc, char * const argv[] )
while( ( option = ewftools_getopt(
argc,
argv,
_SYSTEM_STRING( "A:B:d:ef:F:hHimvV" ) ) ) != (system_integer_t) -1 )
_SYSTEM_STRING( "A:B:d:ef:F:hHims:vV" ) ) ) != (system_integer_t) -1 )
{
switch( option )
{
Expand Down Expand Up @@ -335,6 +338,11 @@ int main( int argc, char * const argv[] )

break;

case (system_integer_t) 's':
option_path_segment_separator = optarg;

break;

case (system_integer_t) 'v':
verbose = 1;

Expand Down Expand Up @@ -522,6 +530,38 @@ int main( int argc, char * const argv[] )
"Unsupported header codepage defaulting to: ascii.\n" );
}
}
if( option_path_segment_separator != NULL )
{
result = info_handle_set_path_segment_separator(
ewfinfo_info_handle,
option_path_segment_separator,
&error );

if( result == -1 )
{
ewftools_output_version_fprint(
stderr,
program );

fprintf(
stderr,
"Unable to set path segment separator.\n" );

goto on_error;
}
else if( result == 0 )
{
ewftools_output_version_fprint(
stderr,
program );

print_header = 0;

fprintf(
stderr,
"Unsupported path segment separator defaulting to: /.\n" );
}
}
#if !defined( HAVE_GLOB_H )
if( ewftools_glob_initialize(
&glob,
Expand Down
Loading

0 comments on commit dd87dd6

Please sign in to comment.