libFlac: Exit at EOS in verify mode

When verify mode is enabled, once decoder flags end of stream,
encode processing is considered complete.

CVE-2021-0561

Signed-off-by: Ralph Giles <giles@thaumas.net>
This commit is contained in:
Neelkamal Semwal 2020-12-18 22:28:36 +05:30 committed by Ralph Giles
parent 479f6038d9
commit e1575e4a7c
No known key found for this signature in database
GPG Key ID: 9259A8F2D2D44C84
1 changed files with 3 additions and 1 deletions

View File

@ -2610,7 +2610,9 @@ FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC
encoder->private_->verify.needs_magic_hack = true;
}
else {
if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder)) {
if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder)
|| (!is_last_block
&& (FLAC__stream_encoder_get_verify_decoder_state(encoder) == FLAC__STREAM_DECODER_END_OF_STREAM))) {
FLAC__bitwriter_release_buffer(encoder->private_->frame);
FLAC__bitwriter_clear(encoder->private_->frame);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA)