mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-30 03:12:08 +00:00
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>
This commit is contained in:
parent
75f847aa6b
commit
7effbee66c
@ -322,6 +322,8 @@ static int aiff_read_packet(AVFormatContext *s,
|
|||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
if (size >= st->codec->block_align)
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
/* Only one stream in an AIFF file */
|
/* Only one stream in an AIFF file */
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;
|
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)
|
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
return 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);
|
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
||||||
/* note: we need to modify the packet size here to handle the last
|
/* 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);
|
ret= av_get_packet(s->pb, pkt, size);
|
||||||
|
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
if (ret <= 0) {
|
if (ret <= 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);
|
ret= av_get_packet(s->pb, pkt, size);
|
||||||
|
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -80,6 +80,7 @@ static int rso_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
||||||
/* note: we need to modify the packet size here to handle the last packet */
|
/* 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);
|
ret= av_get_packet(s->pb, pkt, MAX_SIZE);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
||||||
/* note: we need to modify the packet size here to handle the last
|
/* 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);
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->size = ret;
|
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 av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
int orig_size = size;
|
||||||
size= ffio_limit(s, size);
|
size= ffio_limit(s, size);
|
||||||
|
|
||||||
ret= av_new_packet(pkt, 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);
|
av_free_packet(pkt);
|
||||||
else
|
else
|
||||||
av_shrink_packet(pkt, ret);
|
av_shrink_packet(pkt, ret);
|
||||||
|
if (pkt->size < orig_size)
|
||||||
|
pkt->flags |= AV_PKT_FLAG_CORRUPT;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user