/* 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;
av_log(s, AV_LOG_DEBUG, "Compresssed frame %s tlen=%d dlen=%ld\n", tag, tlen, dlen);
+ if (tlen <= 0)
+ goto seek;
+ if (dlen / 32768 > tlen)
+ goto seek;
+
av_fast_malloc(&uncompressed_buffer, &uncompressed_buffer_size, dlen);
if (!uncompressed_buffer) {
av_log(s, AV_LOG_ERROR, "Failed to alloc %ld bytes\n", dlen);
av_dict_set(&st->metadata, "comment", apic->type, 0);
- av_init_packet(&st->attached_pic);
+ av_packet_unref(&st->attached_pic);
st->attached_pic.buf = apic->buf;
st->attached_pic.data = apic->buf->data;
st->attached_pic.size = apic->buf->size - AV_INPUT_BUFFER_PADDING_SIZE;