[FFmpeg-devel] [PATCH] RTSP-MS 14/15: ASF packet parsing

Michael Niedermayer michaelni
Mon Jul 20 23:25:13 CEST 2009


On Mon, Jun 29, 2009 at 03:21:11PM -0400, Ronald S. Bultje wrote:
[...]
> +/**
> + * From MSDN 2.2.1.4, we learn that ASF data packets over RTP should not
> + * contain any padding. Unfortunately, the header min/max_pktsize are not
> + * updated (thus making min_pktsize invalid). Here, we "fix" these faulty
> + * min_pktsize values in the ASF file header.
> + */
> +static void
> +rtp_asf_fix_header(uint8_t *buf, int len)
> +{
> +    uint8_t *p = buf, *end = buf + len;
> +
> +    if (len < sizeof(ff_asf_guid) * 2 + 22 ||
> +        memcmp(p, ff_asf_header, sizeof(ff_asf_guid))) {
> +        return;
> +    }
> +    p += sizeof(ff_asf_guid) + 14;
> +    do {
> +        uint64_t len = AV_RL64(p + sizeof(ff_asf_guid));
> +        if (memcmp(p, ff_asf_file_header, sizeof(ff_asf_guid))) {
> +            p += len;
> +            continue;
> +        }
> +        /* skip most of the file header, to min_pktsize */
> +        p += 6 * 8 + 3 * 4 + sizeof(ff_asf_guid) * 2;
> +        if (p + 8 <= end && AV_RL32(p) == AV_RL32(p + 4)) {
> +            /* and set that to zero */
> +            AV_WL32(p, 0);
> +        }
> +        break;
> +    } while (end - p >= sizeof(ff_asf_guid) + 8);

this code looks like it will segfault with the right input


> +}
> +
> +/**
> + * The following code is basically a buffered ByteIOContext,
> + * with the added benefit of returning -EAGAIN (instead of 0)
> + * on packet boundaries, such that the ASF demuxer can return
> + * safely and resume business at the next packet.
> + */
> +static int
> +packetizer_read(void *opaque, uint8_t *buf, int buf_size)
> +{
> +    return -EAGAIN;

AVERROR(EAGAIN) ?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

GMX, the mailprovider that uses RBL lists to reject mails from your friends
running their own mailserver at home. The mailprovider that obscures the
origin of mails (mis)identified as viruses. The mailprovider that improves
security my disallowing more secure forms of authentication.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090720/770c774d/attachment.pgp>



More information about the ffmpeg-devel mailing list