Skip to content

Commit

Permalink
Changes for OSS-Fuzz target
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jul 14, 2020
1 parent 8898262 commit 7682991
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 74 deletions.
67 changes: 24 additions & 43 deletions acinclude.m4
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
dnl Checks for required headers and functions
dnl
dnl Version: 20170914
dnl Version: 20200713

dnl Function to detect if libevtx dependencies are available
AC_DEFUN([AX_LIBEVTX_CHECK_LOCAL],
[dnl Headers included in libevtx/libevtx_xml_tag.h
[dnl Check for internationalization functions in libevtx/libevtx_i18n.c
AC_CHECK_FUNCS([bindtextdomain])
dnl Headers included in libevtx/libevtx_xml_tag.h
AC_CHECK_HEADERS([wctype.h])
dnl Functions used in libevtx/libevtx_xml_tag.h
Expand All @@ -16,31 +19,6 @@ AC_DEFUN([AX_LIBEVTX_CHECK_LOCAL],
[Missing function: towupper],
[1])
])
dnl Check for internationalization functions in libevtx/libevtx_i18n.c
AC_CHECK_FUNCS([bindtextdomain])
dnl Check if library should be build with verbose output
AX_COMMON_CHECK_ENABLE_VERBOSE_OUTPUT
dnl Check if library should be build with debug output
AX_COMMON_CHECK_ENABLE_DEBUG_OUTPUT
dnl Check if DLL support is needed
AS_IF(
[test "x$enable_shared" = xyes],
[AS_CASE(
[$host],
[*cygwin* | *mingw*],
[AC_DEFINE(
[HAVE_DLLMAIN],
[1],
[Define to 1 to enable the DllMain function.])
AC_SUBST(
[HAVE_DLLMAIN],
[1])
])
])
])

dnl Function to detect if evtxtools dependencies are available
Expand All @@ -65,28 +43,31 @@ AC_DEFUN([AX_EVTXTOOLS_CHECK_LOCAL],
[Missing headers: stdarg.h and varargs.h],
[1])
])
])

dnl Check if tools should be build as static executables
AX_COMMON_CHECK_ENABLE_STATIC_EXECUTABLES
dnl Check if DLL support is needed
AS_IF(
dnl Function to check if DLL support is needed
AC_DEFUN([AX_LIBEVTX_CHECK_DLL_SUPPORT],
[AS_IF(
[test "x$enable_shared" = xyes && test "x$ac_cv_enable_static_executables" = xno],
[AS_CASE(
[$host],
[*cygwin* | *mingw*],
[AC_SUBST(
[*cygwin* | *mingw* | *msys*],
[AC_DEFINE(
[HAVE_DLLMAIN],
[1],
[Define to 1 to enable the DllMain function.])
AC_SUBST(
[HAVE_DLLMAIN],
[1])
AC_SUBST(
[LIBEVTX_DLL_EXPORT],
["-DLIBEVTX_DLL_EXPORT"])
AC_SUBST(
[LIBEVTX_DLL_IMPORT],
["-DLIBEVTX_DLL_IMPORT"])
])
])
])

dnl Check if OSS-Fuzz build environment is available and fuzz targets should be build
AM_CONDITIONAL(
HAVE_LIB_FUZZING_ENGINE,
[test "x${LIB_FUZZING_ENGINE}" != x])
AC_SUBST(
[LIB_FUZZING_ENGINE],
["${LIB_FUZZING_ENGINE}"])
])

34 changes: 9 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ( 2.59 )

AC_INIT(
[libevtx],
[20200710],
[20200714],
[joachim.metz@gmail.com])

AC_CONFIG_SRCDIR(
Expand All @@ -21,6 +21,7 @@ AC_LIBTOOL_WIN32_DLL
dnl Checks for programs
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_INSTALL

Expand All @@ -45,6 +46,9 @@ AC_SYS_LARGEFILE
dnl Check if shared library support should be disabled
AX_COMMON_CHECK_DISABLE_SHARED_LIBS

dnl Check if tools should be build as static executables
AX_COMMON_CHECK_ENABLE_STATIC_EXECUTABLES

dnl Check if WINAPI support should be enabled
AX_COMMON_CHECK_ENABLE_WINAPI

Expand Down Expand Up @@ -148,32 +152,12 @@ AX_LIBCDIRECTORY_CHECK_ENABLE
dnl Check if evtxtools required headers and functions are available
AX_EVTXTOOLS_CHECK_LOCAL

dnl Check if DLL support is needed
AX_LIBEVTX_CHECK_DLL_SUPPORT

dnl Check if tests required headers and functions are available
AX_TESTS_CHECK_LOCAL

dnl Check if DLL support is needed
AS_IF(
[test "x$enable_shared" = xyes],
[AS_CASE(
[$host],
[*cygwin* | *mingw* | *msys*],
[AC_DEFINE(
[HAVE_DLLMAIN],
[1],
[Define to 1 to enable the DllMain function.])
AC_SUBST(
[HAVE_DLLMAIN],
[1])
AC_SUBST(
[LIBEVTX_DLL_EXPORT],
["-DLIBEVTX_DLL_EXPORT"])
AC_SUBST(
[LIBEVTX_DLL_IMPORT],
["-DLIBEVTX_DLL_IMPORT"])
])
])
AX_TESTS_CHECK_OSSFUZZ

dnl Set additional compiler flags
CFLAGS="$CFLAGS -Wall";
Expand Down
4 changes: 2 additions & 2 deletions m4/libfvalue.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Checks for libfvalue required headers and functions
dnl
dnl Version: 20191231
dnl Version: 20200711

dnl Function to detect if libfvalue is available
dnl ac_libfvalue_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
Expand All @@ -26,7 +26,7 @@ AC_DEFUN([AX_LIBFVALUE_CHECK_LIB],
[test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"],
[PKG_CHECK_MODULES(
[libfvalue],
[libfvalue >= 20191231],
[libfvalue >= 20200711],
[ac_cv_libfvalue=yes],
[ac_cv_libfvalue=check])
])
Expand Down
49 changes: 47 additions & 2 deletions m4/libuna.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Checks for libuna or required headers and functions
dnl
dnl Version: 20200118
dnl Version: 20200711

dnl Function to detect if a specific libuna definition is available.
AC_DEFUN([AX_LIBUNA_CHECK_DEFINITION],
Expand Down Expand Up @@ -43,7 +43,7 @@ AC_DEFUN([AX_LIBUNA_CHECK_LIB],
[test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"],
[PKG_CHECK_MODULES(
[libuna],
[libuna >= 20181006],
[libuna >= 20200711],
[ac_cv_libuna=yes],
[ac_cv_libuna=check])
])
Expand Down Expand Up @@ -427,6 +427,21 @@ AC_DEFUN([AX_LIBUNA_CHECK_LIB],
libuna_utf8_string_with_index_copy_from_utf32,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf8_string_size_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf8_string_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf8_string_with_index_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
dnl UTF-16 string functions
AC_CHECK_LIB(
Expand Down Expand Up @@ -534,6 +549,21 @@ AC_DEFUN([AX_LIBUNA_CHECK_LIB],
libuna_utf16_string_with_index_copy_from_utf32,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf16_string_size_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf16_string_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf16_string_with_index_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
dnl UTF-32 string functions
AC_CHECK_LIB(
Expand Down Expand Up @@ -640,6 +670,21 @@ AC_DEFUN([AX_LIBUNA_CHECK_LIB],
libuna_utf32_string_with_index_copy_from_utf16,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf32_string_size_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf32_string_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
AC_CHECK_LIB(
una,
libuna_utf32_string_with_index_copy_from_scsu_stream,
[ac_cv_libuna_dummy=yes],
[ac_cv_libuna=no])
dnl Check for definitions
AX_LIBUNA_CHECK_DEFINITION(
Expand Down
12 changes: 11 additions & 1 deletion m4/tests.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Functions for testing
dnl
dnl Version: 20200128
dnl Version: 20200712

dnl Function to detect if tests dependencies are available
AC_DEFUN([AX_TESTS_CHECK_LOCAL],
Expand All @@ -21,3 +21,13 @@ AC_DEFUN([AX_TESTS_CHECK_LOCAL],
])
])

dnl Function to detect if OSS-Fuzz build environment is available
AC_DEFUN([AX_TESTS_CHECK_OSSFUZZ],
[AM_CONDITIONAL(
HAVE_LIB_FUZZING_ENGINE,
[test "x${LIB_FUZZING_ENGINE}" != x])
AC_SUBST(
[LIB_FUZZING_ENGINE],
["${LIB_FUZZING_ENGINE}"])
])

8 changes: 8 additions & 0 deletions msvscpp/libuna/libuna.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@
RelativePath="..\..\libuna\libuna_error.c"
>
</File>
<File
RelativePath="..\..\libuna\libuna_scsu.c"
>
</File>
<File
RelativePath="..\..\libuna\libuna_support.c"
>
Expand Down Expand Up @@ -480,6 +484,10 @@
RelativePath="..\..\libuna\libuna_libcerror.h"
>
</File>
<File
RelativePath="..\..\libuna\libuna_scsu.h"
>
</File>
<File
RelativePath="..\..\libuna\libuna_support.h"
>
Expand Down
2 changes: 1 addition & 1 deletion ossfuzz/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bin_PROGRAMS = \
file_fuzzer

file_fuzzer_SOURCES = \
file_fuzzer.c \
file_fuzzer.cc \
ossfuzz_libbfio.h \
ossfuzz_libevtx.h

Expand Down
6 changes: 6 additions & 0 deletions ossfuzz/file_fuzzer.c → ossfuzz/file_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <stddef.h>
#include <stdint.h>

/* Note that some of the OSS-Fuzz engines use C++
*/
extern "C" {

#include "ossfuzz_libbfio.h"
#include "ossfuzz_libevtx.h"

Expand Down Expand Up @@ -91,3 +95,5 @@ int LLVMFuzzerTestOneInput(
return( 0 );
}

} /* extern "C" */

0 comments on commit 7682991

Please sign in to comment.