Commit 7effbee6 authored by Reimar Döffinger's avatar Reimar Döffinger

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: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent 75f847aa
......@@ -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;
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment