From 01e931d2c7f50727d8893268cdc3ae0dbe75c250 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 5 Sep 2022 20:16:13 +0200 Subject: [PATCH] avcodec/flac_parser: add missed opportunity to check crc Fixes #9621 Signed-off-by: Paul B Mahol --- libavcodec/flac_parser.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 11cd5540cf..dd70721696 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -455,7 +455,7 @@ static int check_header_mismatch(FLACParseContext *fpc, int log_level_offset) { FLACFrameInfo *header_fi = &header->fi, *child_fi = &child->fi; - int deduction, deduction_expected = 0, i; + int check_crc, deduction, deduction_expected = 0, i; deduction = check_header_fi_mismatch(fpc, header_fi, child_fi, log_level_offset); /* Check sample and frame numbers. */ @@ -491,8 +491,15 @@ static int check_header_mismatch(FLACParseContext *fpc, "sample/frame number mismatch in adjacent frames\n"); } + if ((fpc->last_fi.frame_or_sample_num + 1 == header_fi->frame_or_sample_num) || + (fpc->last_fi.frame_or_sample_num + fpc->last_fi.blocksize == header_fi->frame_or_sample_num)) { + check_crc = 0; + } else { + check_crc = !deduction && !deduction_expected; + } + /* If we have suspicious headers, check the CRC between them */ - if (deduction && !deduction_expected) { + if (check_crc || (deduction && !deduction_expected)) { FLACHeaderMarker *curr; int read_len; uint8_t *buf; -- 2.37.2