Skip to content

Commit

Permalink
Worked on format support
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 19, 2024
1 parent dabbbb3 commit f779a47
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 48 deletions.
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
CONFIGURE_OPTIONS: "--enable-python"

matrix:
allow_failures:
- TARGET: mingw-w64-gcc-python

install:
- cmd: if [%BUILD_ENVIRONMENT%]==[msbuild] (
git clone https://github.com/libyal/vstools.git ..\vstools )
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ([2.71])

AC_INIT(
[libfwevt],
[20240416],
[20240419],
[joachim.metz@gmail.com])

AC_CONFIG_SRCDIR(
Expand Down
3 changes: 3 additions & 0 deletions include/libfwevt/definitions.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ enum LIBFWEVT_ENDIAN
enum LIBFWEVT_XML_DOCUMENT_READ_FLAGS
{
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS = 0x01,

/* The dependency identifiers flag has been deprecated and is no longer needed
*/
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS = 0x02
};

Expand Down
3 changes: 3 additions & 0 deletions libfwevt/libfwevt_definitions.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
enum LIBFWEVT_XML_DOCUMENT_READ_FLAGS
{
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS = 0x01,

/* The dependency identifiers flag has been deprecated and is no longer needed
*/
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS = 0x02
};

Expand Down
68 changes: 37 additions & 31 deletions libfwevt/libfwevt_xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ int libfwevt_xml_document_read_attribute(

return( -1 );
}
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) == 0 )
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) != 0 )
{
additional_value_size = 4;

Expand Down Expand Up @@ -650,7 +650,7 @@ int libfwevt_xml_document_read_attribute(
libcnotify_print_data(
&( xml_document_data[ xml_document_data_offset ] ),
additional_value_size + 1,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
#if defined( HAVE_DEBUG_OUTPUT )
Expand Down Expand Up @@ -733,7 +733,7 @@ int libfwevt_xml_document_read_attribute(
libcnotify_print_data(
&( xml_document_data[ xml_document_data_offset ] ),
trailing_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
xml_document_data_offset += trailing_data_size;
Expand Down Expand Up @@ -1105,7 +1105,7 @@ int libfwevt_xml_document_read_cdata_section(
libcnotify_print_data(
xml_document_data,
3,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
byte_stream_copy_to_uint16_little_endian(
Expand Down Expand Up @@ -1157,7 +1157,7 @@ int libfwevt_xml_document_read_cdata_section(
libcnotify_print_data(
&( xml_document_data[ 3 ] ),
value_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
if( libfwevt_xml_tag_set_value_type(
Expand Down Expand Up @@ -1691,22 +1691,12 @@ int libfwevt_xml_document_read_element(

return( -1 );
}
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) == 0 )
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) != 0 )
{
additional_value_size = 4;
}
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS ) == 0 )
{
element_size_offset = 1;
}
else
{
element_size_offset = 3;
}
xml_document_data = &( binary_data[ binary_data_offset ] );
xml_document_data_size = binary_data_size - binary_data_offset;

if( xml_document_data_size < ( element_size_offset + 4 + additional_value_size ) )
if( ( binary_data_size < ( 5 + additional_value_size ) )
|| ( binary_data_offset > ( binary_data_size - 5 - additional_value_size ) ) )
{
libcerror_error_set(
error,
Expand All @@ -1730,6 +1720,9 @@ int libfwevt_xml_document_read_element(

goto on_error;
}
xml_document_data = &( binary_data[ binary_data_offset ] );
xml_document_data_size = binary_data_size - binary_data_offset;

do
{
if( ( template_value_array_recursion_depth < 0 )
Expand Down Expand Up @@ -1757,6 +1750,19 @@ int libfwevt_xml_document_read_element(

goto on_error;
}
/* Note that the dependency identifier is an optional value.
*/
element_size_offset = 1;

byte_stream_copy_to_uint32_little_endian(
&( xml_document_data[ element_size_offset ] ),
element_size );

if( ( xml_document_data_size > 7 )
&& ( element_size > ( xml_document_data_size - 7 ) ) )
{
element_size_offset = 3;
}
#if defined( HAVE_DEBUG_OUTPUT )
if( libcnotify_verbose != 0 )
{
Expand All @@ -1771,7 +1777,7 @@ int libfwevt_xml_document_read_element(
libcnotify_print_data(
xml_document_data,
element_size_offset + 4 + additional_value_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
byte_stream_copy_to_uint32_little_endian(
Expand Down Expand Up @@ -1877,7 +1883,7 @@ int libfwevt_xml_document_read_element(
libcnotify_print_data(
&( xml_document_data[ xml_document_data_offset ] ),
trailing_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
xml_document_data_offset += trailing_data_size;
Expand Down Expand Up @@ -2649,7 +2655,7 @@ int libfwevt_xml_document_read_entity_reference(

return( -1 );
}
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) == 0 )
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) != 0 )
{
additional_value_size = 4;
}
Expand Down Expand Up @@ -2681,7 +2687,7 @@ int libfwevt_xml_document_read_entity_reference(
libcnotify_print_data(
xml_document_data,
1 + additional_value_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
#if defined( HAVE_DEBUG_OUTPUT )
Expand Down Expand Up @@ -2766,7 +2772,7 @@ int libfwevt_xml_document_read_entity_reference(
libcnotify_print_data(
&( xml_document_data[ xml_document_data_offset ] ),
trailing_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
xml_token->size += trailing_data_size;
Expand Down Expand Up @@ -3503,7 +3509,7 @@ int libfwevt_xml_document_read_name(
libcnotify_print_data(
xml_document_data,
additional_value_size + 4,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) != 0 )
Expand Down Expand Up @@ -3581,7 +3587,7 @@ int libfwevt_xml_document_read_name(
libcnotify_print_data(
&( xml_document_data[ xml_document_data_offset ] ),
name_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
if( libfwevt_xml_tag_set_name_data(
Expand Down Expand Up @@ -4173,7 +4179,7 @@ int libfwevt_xml_document_read_pi_data(
libcnotify_print_data(
&( xml_document_data[ 3 ] ),
value_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
if( libfwevt_xml_tag_set_value_type(
Expand Down Expand Up @@ -4332,7 +4338,7 @@ int libfwevt_xml_document_read_pi_target(

return( -1 );
}
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) == 0 )
if( ( flags & LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS ) != 0 )
{
additional_value_size = 4;
}
Expand Down Expand Up @@ -4391,7 +4397,7 @@ int libfwevt_xml_document_read_pi_target(
libcnotify_print_data(
xml_document_data,
1 + additional_value_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
#if defined( HAVE_DEBUG_OUTPUT )
Expand Down Expand Up @@ -4485,7 +4491,7 @@ int libfwevt_xml_document_read_pi_target(
libcnotify_print_data(
&( xml_document_data[ 5 ] ),
trailing_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
xml_token->size += trailing_data_size;
Expand Down Expand Up @@ -4822,7 +4828,7 @@ int libfwevt_xml_document_read_template_instance(
libcnotify_print_data(
&( binary_data[ binary_data_offset ] ),
trailing_data_size,
0 );
LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA );
}
#endif
xml_token->size += trailing_data_size;
Expand Down Expand Up @@ -6068,7 +6074,7 @@ int libfwevt_xml_document_substitute_template_value(
binary_data_size,
binary_data_offset,
ascii_codepage,
flags & ~( LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS ),
flags,
template_values_array,
xml_tag,
element_recursion_depth + 1,
Expand Down
9 changes: 5 additions & 4 deletions m4/python.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Functions for Python bindings
dnl
dnl Version: 20240416
dnl Version: 20240418

dnl Function to check if the python binary is available
dnl "python${PYTHON_VERSION} python python# python#.#"
Expand Down Expand Up @@ -78,9 +78,10 @@ AC_DEFUN([AX_PYTHON_CHECK],
dnl For CygWin and MinGW add the -no-undefined linker flag
AS_CASE(
[$host_os],
[cygwin*],[PYTHON_LDFLAGS="${PYTHON_LDFLAGS} -no-undefined"],
[mingw*],[PYTHON_LDFLAGS="${PYTHON_LDFLAGS} -no-undefined"],
[$build],
[*-*-cygwin*],[PYTHON_LDFLAGS="${PYTHON_LDFLAGS} -no-undefined"],
[*-*-mingw*],[PYTHON_LDFLAGS="${PYTHON_LDFLAGS} -no-undefined"],
[*-*-msys*],[PYTHON_LDFLAGS="${PYTHON_LDFLAGS} -no-undefined"],
[*],[])
dnl Check for the existence of Python.h
Expand Down
18 changes: 9 additions & 9 deletions tests/fwevt_test_xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -4518,7 +4518,7 @@ int fwevt_test_xml_document_read(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
&error );

FWEVT_TEST_ASSERT_EQUAL_INT(
Expand All @@ -4538,7 +4538,7 @@ int fwevt_test_xml_document_read(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
&error );

FWEVT_TEST_ASSERT_EQUAL_INT(
Expand Down Expand Up @@ -4628,7 +4628,7 @@ int fwevt_test_xml_document_read_with_template_values(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand Down Expand Up @@ -4687,7 +4687,7 @@ int fwevt_test_xml_document_read_with_template_values(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand All @@ -4709,7 +4709,7 @@ int fwevt_test_xml_document_read_with_template_values(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand All @@ -4731,7 +4731,7 @@ int fwevt_test_xml_document_read_with_template_values(
(size_t) SSIZE_MAX + 1,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand All @@ -4755,7 +4755,7 @@ int fwevt_test_xml_document_read_with_template_values(
65536,
65536,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand All @@ -4779,7 +4779,7 @@ int fwevt_test_xml_document_read_with_template_values(
11,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
NULL,
&error );

Expand Down Expand Up @@ -5311,7 +5311,7 @@ int main(
65536,
0x850,
LIBUNA_CODEPAGE_WINDOWS_1252,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS | LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DEPENDENCY_IDENTIFIERS,
LIBFWEVT_XML_DOCUMENT_READ_FLAG_HAS_DATA_OFFSETS,
&error );

FWEVT_TEST_ASSERT_EQUAL_INT(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_python_module.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Tests Python module functions and types.
#
# Version: 20240416
# Version: 20240417

EXIT_SUCCESS=0;
EXIT_FAILURE=1;
Expand Down Expand Up @@ -143,9 +143,9 @@ source ${TEST_RUNNER};

PLATFORM=`uname -s | sed 's/-.*$//'`;

if test "${PLATFORM}" = "MINGW64_NT";
if test "${PLATFORM}" = "MINGW64_NT" || test "${PLATFORM}" = "MSYS_NT";
then
cp ../${LIBRARY_NAME}/.libs/${LIBRARY_NAME}-1.dll ../${PYTHON_MODULE}/libs/;
cp ../${LIBRARY_NAME}/.libs/*.dll ../${PYTHON_MODULE}/.libs/;
cp ../${PYTHON_MODULE}/.libs/${PYTHON_MODULE}.dll ../${PYTHON_MODULE}/.libs/${PYTHON_MODULE}.pyd;
fi

Expand Down

0 comments on commit f779a47

Please sign in to comment.