Skip to content

Commit

Permalink
Enable fuzzing of writing foreign metadata back on decoding
Browse files Browse the repository at this point in the history
The output file was deleted before writing back foreign metadata
could take place, making that code always fail and not covered by
fuzzing
  • Loading branch information
ktmf01 committed Jul 12, 2024
1 parent 51e61ae commit d48b689
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/flac/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred)
#endif
fclose(d->fout);

#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Always delete output file when fuzzing */
if(error_occurred)
#endif
flac_unlink(d->outfilename);
}
}
Expand Down Expand Up @@ -582,6 +579,11 @@ int DecoderSession_finish_ok(DecoderSession *d)
}
}
}
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Delete output file when fuzzing */
if(0 != d->fout && d->fout != stdout)
flac_unlink(d->outfilename);
#endif
return ok? 0 : 1;
}

Expand Down

0 comments on commit d48b689

Please sign in to comment.