diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2023-01-12 22:05:07 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2023-05-26 00:04:37 +0200 |
commit | 3c982fc61c8a24d7b9f71c3900ae2e114a98b880 (patch) | |
tree | 61e8ba7a217eb8c609bda6d8fcb95f210a9eb867 | |
parent | e82a3c05a4e9134da5487f0473e668910acda467 (diff) | |
download | ffmpeg-3c982fc61c8a24d7b9f71c3900ae2e114a98b880.tar.gz |
avcodec/xpmdec: Check size before allocation to avoid truncation
Fixes:OOM
Fixes:out of array access (no testcase)
Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-6573323838685184
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 95f0f84dae4f040d91f1e60dc5438612c58e8906)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/xpmdec.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index 8aee89dd30..64f13e83f0 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -351,6 +351,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } + if (size > SIZE_MAX / 4) + return AVERROR(ENOMEM); + size *= 4; ptr += mod_strcspn(ptr, ",") + 1; |