[FFmpeg-devel] [PATCH] rmdec.c: prevent zero-length packets

Kostya kostya.shishkov
Sat Mar 21 08:40:10 CET 2009


On Thu, Mar 19, 2009 at 10:39:01PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Tue, Mar 17, 2009 at 8:16 AM, Kostya <kostya.shishkov at gmail.com> wrote:
> > On Tue, Mar 17, 2009 at 08:00:17AM -0400, Ronald S. Bultje wrote:
> >> I don't want to terminate by return with a negative value, since len=0
> >> might just be a random bytesequence that was in the middle of a packet
> >> for whatever codec (i.e. wrong sync).
> >
> > Better add that check to sync - we want correct resyncinc after all.
> 
> Hmk, see attached (will apply in 2 goes, one for moving the -12 and
> one for the actual < to =< change).
> 
> I've looked for a while at adding more length-checks at the bottom of
> sync(), e.g.:
> 
> RMStream *ast = st->priv_data;
> if (ast->audio_framesize) {
>     expected_len = ast->coded_framesize * ast->sub_packet_h / 2;
> } else if (st->codec->codec_id == CODEC_ID_RA_144) {
>     expected_len = RAW_PACKET_SIZE;
> }
> 
> and maybe you could do a few more like this, e.g. if it's AAC then it
> should be at least 3*(AV_RB16(first_two_bytes) + 1)-1, you could
> probably figure something for video/ac3 as well. Worth it or too much
> trouble?

Probably too much trouble and is rather unclean (codec-dependent data in
too many places).
And patch is ok.
 
> Ronald




More information about the ffmpeg-devel mailing list