08989d
commit e1575e4a7c5157cbf4e4a16dbd39b74f7174c7be
08989d
Author: Neelkamal Semwal <neelkamal.semwal@ittiam.com>
08989d
Date:   Fri Dec 18 22:28:36 2020 +0530
08989d
08989d
    libFlac: Exit at EOS in verify mode
08989d
    
08989d
    When verify mode is enabled, once decoder flags end of stream,
08989d
    encode processing is considered complete.
08989d
    
08989d
    CVE-2021-0561
08989d
    
08989d
    Signed-off-by: Ralph Giles <giles@thaumas.net>
08989d
08989d
diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c
08989d
index 4c91247f..7109802c 100644
08989d
--- a/src/libFLAC/stream_encoder.c
08989d
+++ b/src/libFLAC/stream_encoder.c
08989d
@@ -2610,7 +2610,9 @@ FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC
08989d
 			encoder->private_->verify.needs_magic_hack = true;
08989d
 		}
08989d
 		else {
08989d
-			if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder)) {
08989d
+			if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder)
08989d
+			    || (!is_last_block
08989d
+				    && (FLAC__stream_encoder_get_verify_decoder_state(encoder) == FLAC__STREAM_DECODER_END_OF_STREAM))) {
08989d
 				FLAC__bitwriter_release_buffer(encoder->private_->frame);
08989d
 				FLAC__bitwriter_clear(encoder->private_->frame);
08989d
 				if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA)