diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 036e9df9c9..70ee4c911f 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -611,7 +611,10 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, /* mimetype */ if (isv34) { - taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); + int ret = avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); + if (ret < 0 || ret >= taglen) + goto fail; + taglen -= ret; } else { if (avio_read(pb, mimetype, 3) < 0) goto fail;