summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-04-30 22:58:27 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-05-01 23:20:52 +0200
commit7effbee66cf457c62f795d9b9ed3a1110b364b89 (patch)
treea406f659aff1b694e66774acb77ec856024d81d8
parent75f847aa6b1bc88733e59d680809f614977b4c07 (diff)
Mark truncated packets as corrupt in av_get_packet.
Manually remove that flag again for formats that read an arbitrary amount of data and thus truncation is not an error. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
-rw-r--r--libavformat/aiffdec.c2
-rw-r--r--libavformat/apc.c1
-rw-r--r--libavformat/au.c1
-rw-r--r--libavformat/mp3dec.c1
-rw-r--r--libavformat/pcmdec.c1
-rw-r--r--libavformat/rsodec.c1
-rw-r--r--libavformat/sol.c1
-rw-r--r--libavformat/soxdec.c1
-rw-r--r--libavformat/utils.c3
9 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index c94863c285..4083316450 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -322,6 +322,8 @@ static int aiff_read_packet(AVFormatContext *s,
if (res < 0)
return res;
+ if (size >= st->codec->block_align)
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* Only one stream in an AIFF file */
pkt->stream_index = 0;
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;
diff --git a/libavformat/apc.c b/libavformat/apc.c
index 389eba7b0a..2e160ccab5 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -76,6 +76,7 @@ static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
return 0;
}
diff --git a/libavformat/au.c b/libavformat/au.c
index aa52a96ea1..4dd84bfdeb 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -187,6 +187,7 @@ static int au_read_packet(AVFormatContext *s,
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
if (ret < 0)
return ret;
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 31d64b2921..edfee164b4 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -175,6 +175,7 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
ret= av_get_packet(s->pb, pkt, size);
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret <= 0) {
if(ret<0)
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index eacac2f353..94f6b4ae25 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -36,6 +36,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
ret= av_get_packet(s->pb, pkt, size);
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
if (ret < 0)
return ret;
diff --git a/libavformat/rsodec.c b/libavformat/rsodec.c
index 1886116678..3933fc08c6 100644
--- a/libavformat/rsodec.c
+++ b/libavformat/rsodec.c
@@ -80,6 +80,7 @@ static int rso_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last packet */
diff --git a/libavformat/sol.c b/libavformat/sol.c
index 698502e036..b2ecd82c46 100644
--- a/libavformat/sol.c
+++ b/libavformat/sol.c
@@ -133,6 +133,7 @@ static int sol_read_packet(AVFormatContext *s,
ret= av_get_packet(s->pb, pkt, MAX_SIZE);
if (ret < 0)
return ret;
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last
diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c
index 9ca7673175..a0b65d9160 100644
--- a/libavformat/soxdec.c
+++ b/libavformat/soxdec.c
@@ -138,6 +138,7 @@ static int sox_read_packet(AVFormatContext *s,
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return AVERROR(EIO);
+ pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
pkt->size = ret;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d6e7f69ec5..d9dc2fb731 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -297,6 +297,7 @@ int ffio_limit(AVIOContext *s, int size)
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
{
int ret;
+ int orig_size = size;
size= ffio_limit(s, size);
ret= av_new_packet(pkt, size);
@@ -311,6 +312,8 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
av_free_packet(pkt);
else
av_shrink_packet(pkt, ret);
+ if (pkt->size < orig_size)
+ pkt->flags |= AV_PKT_FLAG_CORRUPT;
return ret;
}