summaryrefslogtreecommitdiff
path: root/libavformat/flacdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-08 22:33:32 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-08 22:33:32 +0200
commitca1f2b3e10b79958d36db296f142fbd232f997e6 (patch)
tree4ed519b7bf7ece90209c4e2e0f1c81423bf16f19 /libavformat/flacdec.c
parentd8ce478c43d9096bcf38b50c849e9ed45647542d (diff)
parent66a297975d19e0d9b8a5ff8a723dcd2116a506ce (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: cmutils: include shellapi.h on Win32 (for CommandLineToArgvW). x86/timer: implement an intrinsic-based version for rdtsc (AV_READ_TIME). id3v2: add a mimetype for bmp pictures. flacdec: be less strict when parsing attached pictures. flacdec: don't create an attached picture stream until we have all information. Conflicts: configure Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/flacdec.c')
-rw-r--r--libavformat/flacdec.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index cd73df6ad4..cd84cc6ad5 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -38,10 +38,6 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
int type, width, height;
int len, ret = 0;
- st = avformat_new_stream(s, NULL);
- if (!st)
- return AVERROR(ENOMEM);
-
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
@@ -50,8 +46,11 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
type = avio_rb32(pb);
if (type >= FF_ARRAY_ELEMS(ff_id3v2_picture_types) || type < 0) {
av_log(s, AV_LOG_ERROR, "Invalid picture type: %d.\n", type);
- ret = AVERROR_INVALIDDATA;
- goto fail;
+ if (s->error_recognition & AV_EF_EXPLODE) {
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+ type = 0;
}
/* picture mimetype */
@@ -60,7 +59,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
avio_read(pb, mimetype, FFMIN(len, sizeof(mimetype) - 1)) != len) {
av_log(s, AV_LOG_ERROR, "Could not read mimetype from an attached "
"picture.\n");
- ret = AVERROR_INVALIDDATA;
+ if (s->error_recognition & AV_EF_EXPLODE)
+ ret = AVERROR_INVALIDDATA;
goto fail;
}
mimetype[len] = 0;
@@ -75,7 +75,8 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
if (id == CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n",
mimetype);
- ret = AVERROR_INVALIDDATA;
+ if (s->error_recognition & AV_EF_EXPLODE)
+ ret = AVERROR_INVALIDDATA;
goto fail;
}
@@ -88,7 +89,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
}
if (avio_read(pb, desc, len) != len) {
- ret = AVERROR(EIO);
+ av_log(s, AV_LOG_ERROR, "Error reading attached picture description.\n");
+ if (s->error_recognition & AV_EF_EXPLODE)
+ ret = AVERROR(EIO);
goto fail;
}
desc[len] = 0;
@@ -102,7 +105,9 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
/* picture data */
len = avio_rb32(pb);
if (len <= 0) {
- ret = AVERROR_INVALIDDATA;
+ av_log(s, AV_LOG_ERROR, "Invalid attached picture size: %d.\n", len);
+ if (s->error_recognition & AV_EF_EXPLODE)
+ ret = AVERROR_INVALIDDATA;
goto fail;
}
if (!(data = av_malloc(len))) {
@@ -110,7 +115,15 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
goto fail;
}
if (avio_read(pb, data, len) != len) {
- ret = AVERROR(EIO);
+ av_log(s, AV_LOG_ERROR, "Error reading attached picture data.\n");
+ if (s->error_recognition & AV_EF_EXPLODE)
+ ret = AVERROR(EIO);
+ goto fail;
+ }
+
+ st = avformat_new_stream(s, NULL);
+ if (!st) {
+ ret = AVERROR(ENOMEM);
goto fail;
}