From b6c2498a5902766f924cc8728ac65d4fbfd95238 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 21 Apr 2025 14:06:41 -0300 Subject: [PATCH] avformat/takdec.c: return proper error codes for avio_read() failures Suggested-by: Nicolas George Signed-off-by: James Almer --- libavformat/takdec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/takdec.c b/libavformat/takdec.c index 01bb16ea7b..e6de269b05 100644 --- a/libavformat/takdec.c +++ b/libavformat/takdec.c @@ -96,9 +96,10 @@ static int tak_read_header(AVFormatContext *s) memset(buffer + size - 3, 0, AV_INPUT_BUFFER_PADDING_SIZE); ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); - if (avio_read(pb, buffer, size - 3) != size - 3) { + ret = avio_read(pb, buffer, size - 3); + if (ret != size - 3) { av_freep(&buffer); - return AVERROR(EIO); + return ret < 0 ? ret : AVERROR_INVALIDDATA; } if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { av_log(s, AV_LOG_ERROR, "%d metadata block CRC error.\n", type); @@ -116,8 +117,9 @@ static int tak_read_header(AVFormatContext *s) if (size != 19) return AVERROR_INVALIDDATA; ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); - if (avio_read(pb, md5, 16) != 16) - return AVERROR(EIO); + ret = avio_read(pb, md5, 16); + if (ret != 16) + return ret < 0 ? ret : AVERROR_INVALIDDATA; if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { av_log(s, AV_LOG_ERROR, "MD5 metadata block CRC error.\n"); if (s->error_recognition & AV_EF_EXPLODE)