Skip to content

Commit

Permalink
Changes for EWF write
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Nov 28, 2020
1 parent 7e90bd3 commit 2ed2c9a
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- architecture: 'x64'
compiler: 'gcc'
configure_options: '--enable-wide-character-type'
- architecture: 'x64'
compiler: 'gcc'
configure_options: '--with-zlib=no'
- architecture: 'x64'
compiler: 'gcc'
configure_options: '--with-openssl=no'
Expand Down
30 changes: 16 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
environment:
nuget_token:
secure: s3Sl1ZiRw+J7YD+2wr1elu0unq6koZek+JmOcYKfDPfwrz2NigSu5SD8WvlwdIcH
matrix:
- TARGET: vs2008
BUILD_ENVIRONMENT: msbuild
Expand Down Expand Up @@ -153,7 +155,8 @@ install:
- cmd: git clone https://github.com/codecov/codecov-bash.git ..\codecov-bash
- cmd: if [%BUILD_ENVIRONMENT%]==[msbuild] (
git clone https://github.com/libyal/vstools.git ..\vstools )
- ps: .\syncwinflexbison.ps1
- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild") {
.\syncwinflexbison.ps1 }
- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild") {
.\synczlib.ps1 }
- ps: If ($env:BUILD_ENVIRONMENT -eq "msbuild") {
Expand Down Expand Up @@ -200,9 +203,9 @@ install:
Else {
.\builddokan.ps1 -UseLegacyVersion }
}
- sh: if test ${BUILD_ENVIRONMENT} = "xcode" || test ${BUILD_ENVIRONMENT} = "python"; then brew update; fi
- sh: if test ${BUILD_ENVIRONMENT} = "xcode" || test ${BUILD_ENVIRONMENT} = "python"; then brew install gettext gnu-sed || true; fi
- sh: if test ${BUILD_ENVIRONMENT} = "python"; then brew python3 || true; fi
- sh: if test ${BUILD_ENVIRONMENT} = "xcode" || test ${BUILD_ENVIRONMENT} = "python"; then brew update -q; fi
- sh: if test ${BUILD_ENVIRONMENT} = "xcode" || test ${BUILD_ENVIRONMENT} = "python"; then brew install -q gettext gnu-sed || true; fi
- sh: if test ${BUILD_ENVIRONMENT} = "python"; then brew install -q python3 || true; fi
- ps: If ($env:BUILD_ENVIRONMENT -eq "python") {
Invoke-Expression "${env:PYTHON} -m pip install -U pip setuptools twine wheel" }
- cmd: if [%BUILD_ENVIRONMENT%]==[cygwin] (
Expand Down Expand Up @@ -231,6 +234,10 @@ build_script:
- ps: If ($env:TARGET -eq "vs2017") {
.\build.ps1 -VisualStudioVersion 2017 -Platform Win32 -VSToolsOptions "--extend-with-x64 --no-python-dll --with-dokany";
.\build.ps1 -VisualStudioVersion 2017 -Platform x64 -VSToolsOptions "--extend-with-x64 --no-python-dll --with-dokany" }
- cmd: if [%TARGET%]==[vs2017] (
move msvscpp vs2008 &&
move vs2017 msvscpp &&
nuget pack libewf.nuspec )
- ps: If ($env:TARGET -eq "vs2019") {
.\build.ps1 -VisualStudioVersion 2019 -VSToolsOptions "--extend-with-x64 --no-python-dll --with-dokany" }
- sh: if test ${BUILD_ENVIRONMENT} = "xcode" || test ${BUILD_ENVIRONMENT} = "python"; then export PATH="/usr/local/opt/gettext/bin:$PATH"; export SED="/usr/local/bin/gsed"; tests/build.sh ${CONFIGURE_OPTIONS}; fi
Expand Down Expand Up @@ -272,14 +279,9 @@ after_test:

artifacts:
- path: \*.nupkg
- path: dist\*.whl

deploy_script:
- ps: If ($env:APPVEYOR_REPO_TAG -eq "true" -and $isWindows -and $env:TARGET -eq "vs2017") {
Invoke-Expression "nuget push *.nupkg -NonInteractive -NoSymbols -Source https://api.nuget.org/v3/index.json -ApiKey ${env:NUGET_TOKEN}" }

deploy:
- provider: NuGet
skip_symbols: true
api_key:
secure: gCkz3PNGORdxJGl+aegOa7OJ4IQFHC/FqgCzbirMk7nyNFCuZzc1/ne2174eYxsw
artifact: /.*\.nupkg/
on:
branch: master
appveyor_repo_tag: true
target: vs2017
26 changes: 25 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ( 2.59 )

AC_INIT(
[libewf],
[20140810],
[20140811],
[[email protected]])

AC_CONFIG_SRCDIR(
Expand Down Expand Up @@ -129,6 +129,29 @@ AX_LIBHMAC_CHECK_ENABLE
dnl Check if libewf required headers and functions are available
AX_LIBEWF_CHECK_LOCAL

AS_IF(
[test "x$ac_cv_uncompress" = xzlib],
[ac_cv_enable_write_support=yes],
[ac_cv_enable_write_support=no])

AS_IF(
[test "x$ac_cv_uncompress" = xzlib],
[AC_DEFINE(
[HAVE_WRITE_SUPPORT],
[1],
[Define to 1 if write support is available.])
AC_SUBST(
[HAVE_WRITE_SUPPORT],
[1]) ],
[AC_SUBST(
[HAVE_WRITE_SUPPORT],
[0])
])

AM_CONDITIONAL(
HAVE_WRITE_TESTS,
[test "x$ac_cv_uncompress" = xzlib])

dnl Check if libewf should be build with version 1 API
AX_LIBEWF_CHECK_ENABLE_V1_API

Expand Down Expand Up @@ -287,6 +310,7 @@ Building:
Features:
Multi-threading support: $ac_cv_libcthreads_multi_threading
Wide character type support: $ac_cv_enable_wide_character_type
Write support: $ac_cv_enable_write_support
ewftools are build as static executables: $ac_cv_enable_static_executables
Python (pyewf) support: $ac_cv_enable_python
Verbose output: $ac_cv_enable_verbose_output
Expand Down
6 changes: 5 additions & 1 deletion ewftools/process_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,14 @@ int process_status_update(
process_status->output_stream,
bytes_total,
total_number_of_seconds );

fprintf(
process_status->output_stream,
".\n" );
}
fprintf(
process_status->output_stream,
".\n\n" );
"\n" );
}
}
return( 1 );
Expand Down
2 changes: 1 addition & 1 deletion libewf.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>libewf</id>
<version>20140810</version>
<version>20140811</version>
<authors>Joachim Metz</authors>
<owners>joachimmetz</owners>
<license type="expression">LGPL-3.0-or-later</license>
Expand Down
60 changes: 58 additions & 2 deletions libewf/libewf_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,19 @@ int libewf_handle_open(

return( -1 );
}
#if !defined( HAVE_WRITE_SUPPORT )
if( ( access_flags & LIBEWF_ACCESS_FLAG_WRITE ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
"%s: write access currently not supported - compiled without zlib.",
function );

return( -1 );
}
#endif
if( libbfio_pool_initialize(
&file_io_pool,
0,
Expand Down Expand Up @@ -1418,6 +1431,19 @@ int libewf_handle_open_wide(

return( -1 );
}
#if !defined( HAVE_WRITE_SUPPORT )
if( ( access_flags & LIBEWF_ACCESS_FLAG_WRITE ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
"%s: write access currently not supported - compiled without zlib.",
function );

return( -1 );
}
#endif
if( libbfio_pool_initialize(
&file_io_pool,
0,
Expand Down Expand Up @@ -1738,7 +1764,8 @@ int libewf_handle_open_wide(
}
return( -1 );
}
#endif

#endif /* defined( HAVE_WIDE_CHARACTER_TYPE ) */

/* Opens a set of EWF file(s) using a Basic File IO (bfio) pool
* Returns 1 if successful or -1 on error
Expand Down Expand Up @@ -1894,6 +1921,19 @@ int libewf_handle_open_file_io_pool(

return( -1 );
}
#if !defined( HAVE_WRITE_SUPPORT )
if( ( access_flags & LIBEWF_ACCESS_FLAG_WRITE ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
"%s: write access currently not supported - compiled without zlib.",
function );

return( -1 );
}
#endif
if( internal_handle->segment_table == NULL )
{
if( libewf_segment_table_initialize(
Expand Down Expand Up @@ -3937,7 +3977,7 @@ int libewf_handle_close(
"%s: unable to finalize write.",
function );

return( -1 );
result = -1;
}
}
if( internal_handle->file_io_pool_created_in_library != 0 )
Expand Down Expand Up @@ -3985,6 +4025,22 @@ int libewf_handle_close(

result = -1;
}
if( internal_handle->chunk_data != NULL )
{
if( libewf_chunk_data_free(
&( internal_handle->chunk_data ),
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
"%s: unable to free chunk data.",
function );

result = -1;
}
}
if( internal_handle->read_io_handle != NULL )
{
if( libewf_read_io_handle_free(
Expand Down
7 changes: 6 additions & 1 deletion libewf/libewf_write_io_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ int libewf_write_io_handle_clone(
"%s: unable to copy source to destination write IO handle.",
function );

goto on_error;
memory_free(
*destination_write_io_handle );

*destination_write_io_handle = NULL;

return( -1 );
}
( *destination_write_io_handle )->data_section = NULL;
( *destination_write_io_handle )->table_offsets = NULL;
Expand Down
2 changes: 1 addition & 1 deletion libmfdata/libmfdata_list_element.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int libmfdata_list_element_free(
{
if( internal_element->group_values != NULL )
{
if( internal_element->group_values->number_of_elements == 1 )
if( internal_element->group_values->number_of_elements <= 1 )
{
if( libmfdata_group_free(
&( internal_element->group_values ),
Expand Down
40 changes: 38 additions & 2 deletions m4/libbfio.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Checks for libbfio required headers and functions
dnl
dnl Version: 20191230
dnl Version: 20201125

dnl Function to detect if libbfio is available
dnl ac_libbfio_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
Expand All @@ -26,7 +26,7 @@ AC_DEFUN([AX_LIBBFIO_CHECK_LIB],
[test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"],
[PKG_CHECK_MODULES(
[libbfio],
[libbfio >= 20191230],
[libbfio >= 20201125],
[ac_cv_libbfio=yes],
[ac_cv_libbfio=check])
])
Expand Down Expand Up @@ -100,11 +100,21 @@ AC_DEFUN([AX_LIBBFIO_CHECK_LIB],
libbfio_handle_read_buffer,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_handle_read_buffer_at_offset,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_handle_write_buffer,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_handle_write_buffer_at_offset,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_handle_seek_offset,
Expand Down Expand Up @@ -261,11 +271,21 @@ AC_DEFUN([AX_LIBBFIO_CHECK_LIB],
libbfio_pool_read_buffer,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_pool_read_buffer_at_offset,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_pool_write_buffer,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_pool_write_buffer_at_offset,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AC_CHECK_LIB(
bfio,
libbfio_pool_seek_offset,
Expand All @@ -282,6 +302,22 @@ AC_DEFUN([AX_LIBBFIO_CHECK_LIB],
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
dnl File pool functions
AC_CHECK_LIB(
bfio,
libbfio_file_pool_open,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
AS_IF(
[test "x$ac_cv_enable_wide_character_type" != xno],
[AC_CHECK_LIB(
bfio,
libbfio_file_pool_open_wide,
[ac_cv_libbfio_dummy=yes],
[ac_cv_libbfio=no])
])
ac_cv_libbfio_LIBADD="-lbfio"])
])
AS_IF(
Expand Down
Loading

0 comments on commit 2ed2c9a

Please sign in to comment.