-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied updates and added column, record and table OSS-Fuzz targets
- Loading branch information
1 parent
70fccda
commit cffab34
Showing
7 changed files
with
479 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* OSS-Fuzz target for libesedb column type | ||
* | ||
* Copyright (C) 2011-2020, Joachim Metz <joachim.metz@gmail.com> | ||
* | ||
* Refer to AUTHORS for acknowledgements. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
/* Note that some of the OSS-Fuzz engines use C++ | ||
*/ | ||
extern "C" { | ||
|
||
#include "ossfuzz_libbfio.h" | ||
#include "ossfuzz_libesedb.h" | ||
|
||
#if !defined( LIBESEDB_HAVE_BFIO ) | ||
|
||
/* Opens a file using a Basic File IO (bfio) handle | ||
* Returns 1 if successful or -1 on error | ||
*/ | ||
LIBESEDB_EXTERN \ | ||
int libesedb_file_open_file_io_handle( | ||
libesedb_file_t *file, | ||
libbfio_handle_t *file_io_handle, | ||
int access_flags, | ||
libesedb_error_t **error ); | ||
|
||
#endif /* !defined( LIBESEDB_HAVE_BFIO ) */ | ||
|
||
int LLVMFuzzerTestOneInput( | ||
const uint8_t *data, | ||
size_t size ) | ||
{ | ||
libbfio_handle_t *file_io_handle = NULL; | ||
libesedb_column_t *column = NULL; | ||
libesedb_file_t *file = NULL; | ||
libesedb_table_t *table = NULL; | ||
int number_of_columns = 0; | ||
int number_of_tables = 0; | ||
|
||
if( libbfio_memory_range_initialize( | ||
&file_io_handle, | ||
NULL ) != 1 ) | ||
{ | ||
return( 0 ); | ||
} | ||
if( libbfio_memory_range_set( | ||
file_io_handle, | ||
(uint8_t *) data, | ||
size, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libbfio; | ||
} | ||
if( libesedb_file_initialize( | ||
&file, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libbfio; | ||
} | ||
if( libesedb_file_open_file_io_handle( | ||
file, | ||
file_io_handle, | ||
LIBESEDB_OPEN_READ, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_file; | ||
} | ||
if( libesedb_file_get_number_of_tables( | ||
file, | ||
&number_of_tables, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_file; | ||
} | ||
if( number_of_tables > 0 ) | ||
{ | ||
if( libesedb_file_get_table( | ||
file, | ||
0, | ||
&table, | ||
NULL ) == 1 ) | ||
{ | ||
if( libesedb_table_get_number_of_columns( | ||
table, | ||
&number_of_columns, | ||
0, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_table; | ||
} | ||
if( number_of_columns > 0 ) | ||
{ | ||
if( libesedb_table_get_column( | ||
table, | ||
0, | ||
&column, | ||
0, | ||
NULL ) == 1 ) | ||
{ | ||
libesedb_column_free( | ||
&column, | ||
NULL ); | ||
} | ||
} | ||
on_error_libesedb_table: | ||
libesedb_table_free( | ||
&table, | ||
NULL ); | ||
} | ||
} | ||
libesedb_file_close( | ||
file, | ||
NULL ); | ||
|
||
on_error_libesedb_file: | ||
libesedb_file_free( | ||
&file, | ||
NULL ); | ||
|
||
on_error_libbfio: | ||
libbfio_handle_free( | ||
&file_io_handle, | ||
NULL ); | ||
|
||
return( 0 ); | ||
} | ||
|
||
} /* extern "C" */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* OSS-Fuzz target for libesedb record type | ||
* | ||
* Copyright (C) 2011-2020, Joachim Metz <joachim.metz@gmail.com> | ||
* | ||
* Refer to AUTHORS for acknowledgements. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
/* Note that some of the OSS-Fuzz engines use C++ | ||
*/ | ||
extern "C" { | ||
|
||
#include "ossfuzz_libbfio.h" | ||
#include "ossfuzz_libesedb.h" | ||
|
||
#if !defined( LIBESEDB_HAVE_BFIO ) | ||
|
||
/* Opens a file using a Basic File IO (bfio) handle | ||
* Returns 1 if successful or -1 on error | ||
*/ | ||
LIBESEDB_EXTERN \ | ||
int libesedb_file_open_file_io_handle( | ||
libesedb_file_t *file, | ||
libbfio_handle_t *file_io_handle, | ||
int access_flags, | ||
libesedb_error_t **error ); | ||
|
||
#endif /* !defined( LIBESEDB_HAVE_BFIO ) */ | ||
|
||
int LLVMFuzzerTestOneInput( | ||
const uint8_t *data, | ||
size_t size ) | ||
{ | ||
libbfio_handle_t *file_io_handle = NULL; | ||
libesedb_file_t *file = NULL; | ||
libesedb_record_t *record = NULL; | ||
libesedb_table_t *table = NULL; | ||
int number_of_records = 0; | ||
int number_of_tables = 0; | ||
|
||
if( libbfio_memory_range_initialize( | ||
&file_io_handle, | ||
NULL ) != 1 ) | ||
{ | ||
return( 0 ); | ||
} | ||
if( libbfio_memory_range_set( | ||
file_io_handle, | ||
(uint8_t *) data, | ||
size, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libbfio; | ||
} | ||
if( libesedb_file_initialize( | ||
&file, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libbfio; | ||
} | ||
if( libesedb_file_open_file_io_handle( | ||
file, | ||
file_io_handle, | ||
LIBESEDB_OPEN_READ, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_file; | ||
} | ||
if( libesedb_file_get_number_of_tables( | ||
file, | ||
&number_of_tables, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_file; | ||
} | ||
if( number_of_tables > 0 ) | ||
{ | ||
if( libesedb_file_get_table( | ||
file, | ||
0, | ||
&table, | ||
NULL ) == 1 ) | ||
{ | ||
if( libesedb_table_get_number_of_records( | ||
table, | ||
&number_of_records, | ||
NULL ) != 1 ) | ||
{ | ||
goto on_error_libesedb_table; | ||
} | ||
if( number_of_records > 0 ) | ||
{ | ||
if( libesedb_table_get_record( | ||
table, | ||
0, | ||
&record, | ||
NULL ) == 1 ) | ||
{ | ||
libesedb_record_free( | ||
&record, | ||
NULL ); | ||
} | ||
} | ||
on_error_libesedb_table: | ||
libesedb_table_free( | ||
&table, | ||
NULL ); | ||
} | ||
} | ||
libesedb_file_close( | ||
file, | ||
NULL ); | ||
|
||
on_error_libesedb_file: | ||
libesedb_file_free( | ||
&file, | ||
NULL ); | ||
|
||
on_error_libbfio: | ||
libbfio_handle_free( | ||
&file_io_handle, | ||
NULL ); | ||
|
||
return( 0 ); | ||
} | ||
|
||
} /* extern "C" */ | ||
|
Oops, something went wrong.