Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions oss-fuzz/common.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
extern int alloc_check_threshold, alloc_check_counter, alloc_check_keep_failing;
int alloc_check_threshold = INT32_MAX, alloc_check_counter = 0, alloc_check_keep_failing = 0;

extern char* allowed_filename;
char* allowed_filename = NULL;
4 changes: 4 additions & 0 deletions oss-fuzz/tool_metaflac.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
share__opterr = 0;
share__optind = 0;

allowed_filename = NULL;


if(size < 2)
return 0;
Expand Down Expand Up @@ -88,6 +90,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

argv[numarg++] = filename;

allowed_filename = filename;

/* Create file to feed to stdin */
if(use_stdin) {
file_to_fuzz = mkstemp(filename_stdin);
Expand Down
15 changes: 14 additions & 1 deletion src/metaflac/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,23 @@ FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options)

if(options->num_files > 0) {
unsigned i = 0;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
extern char* allowed_filename;
#endif
if(0 == (options->filenames = safe_malloc_mul_2op_(sizeof(char*), /*times*/options->num_files)))
die("out of memory allocating space for file names list");
while(share__optind < argc)
options->filenames[i++] = local_strdup(argv[share__optind++]);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if(strcmp(argv[share__optind],allowed_filename) == 0)
#endif
options->filenames[i++] = local_strdup(argv[share__optind++]);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
else {
if(options->num_files > 0)
options->num_files--;
share__optind++;
}
#endif
}

if(options->args.checks.num_major_ops > 0) {
Expand Down
Loading