aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaterina Barone-Adesi <katerinab@gmail.com>2014-09-16 01:40:24 +0200
committerDiego Biurrun <diego@biurrun.de>2014-09-17 07:50:55 -0700
commitb989bb7adee0f3286dcaa63c5cd0753eac45f6be (patch)
tree8bc0153d43301bad03a4b44ff6ba39679be93706
parent893b353362bc220280efd8d14c4878a1cafe18a8 (diff)
downloadffmpeg-b989bb7adee0f3286dcaa63c5cd0753eac45f6be.tar.gz
apetag: Fix APE tag size check
The size variable is (correctly) unsigned, but is passed to several functions which take signed parameters, such as avio_read, sometimes after having numbers added to it. So ensure that size remains within the bounds that these functions can handle. (cherry picked from commit 56ac2cbd0464e0146e62c91843e2b1f5e0908504) Signed-off-by: Diego Biurrun <diego@biurrun.de> Conflicts: libavformat/apetag.c
-rw-r--r--libavformat/apetag.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 2390bfaad3..41ba054d69 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -51,8 +51,10 @@ static int ape_tag_read_field(AVFormatContext *s)
av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key);
return -1;
}
- if (size >= UINT_MAX)
- return -1;
+ if (size > INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
+ av_log(s, AV_LOG_ERROR, "APE tag size too large.\n");
+ return AVERROR_INVALIDDATA;
+ }
value = av_malloc(size+1);
if (!value)
return AVERROR(ENOMEM);