X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fid3v2.c;h=b43ab1745f27dae3636eff5fb2592d9eea687240;hb=5ca7eb36b7353f9e6af05a5a952eead5f6d326dd;hp=f7de26a1d8e543eadc1d2e7ff22d2d4d1471b3dc;hpb=4069096dd535ee99175c2a29c1a1f59c3fc110c1;p=ffmpeg diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index f7de26a1d8e..b43ab1745f2 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -36,6 +36,7 @@ #include "libavutil/bprint.h" #include "libavutil/dict.h" #include "libavutil/intreadwrite.h" +#include "libavcodec/png.h" #include "avio_internal.h" #include "internal.h" #include "id3v1.h" @@ -590,7 +591,7 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, int isv34) { int enc, pic_type; - char mimetype[64]; + char mimetype[64] = {0}; const CodecMime *mime = ff_id3v2_mime_tags; enum AVCodecID id = AV_CODEC_ID_NONE; ID3v2ExtraMetaAPIC *apic = NULL; @@ -612,7 +613,9 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, if (isv34) { taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); } else { - avio_read(pb, mimetype, 3); + if (avio_read(pb, mimetype, 3) < 0) + goto fail; + mimetype[3] = 0; taglen -= 3; } @@ -1156,7 +1159,7 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta) st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = apic->id; - if (AV_RB64(apic->buf->data) == 0x89504e470d0a1a0a) + if (AV_RB64(apic->buf->data) == PNGSIG) st->codecpar->codec_id = AV_CODEC_ID_PNG; if (apic->description[0])