Ticket #608: 0001-Fix-segfault-on-UDP-reading.patch

File 0001-Fix-segfault-on-UDP-reading.patch, 1.2 KB (added by Krieger, 8 years ago)

Git patch

  • libavformat/udp.c

    From 6d81d553bb75d3ed9d6a13f00fe21bf1f0474eb5 Mon Sep 17 00:00:00 2001
    From: Andrey Utkin <andrey.krieger.utkin@gmail.com>
    Date: Thu, 3 Nov 2011 07:00:15 +0000
    Subject: [PATCH] Fix segfault on UDP reading
    
    ---
     libavformat/udp.c |    4 ++++
     1 files changed, 4 insertions(+), 0 deletions(-)
    
    diff --git a/libavformat/udp.c b/libavformat/udp.c
    index 151e070..59d1f74 100644
    a b static int udp_read(URLContext *h, uint8_t *buf, int size) 
    546546            avail = av_fifo_size(s->fifo);
    547547            if (avail) { // >=size) {
    548548                uint8_t tmp[4];
     549                int skip = 0;
    549550
    550551                av_fifo_generic_read(s->fifo, tmp, 4, NULL);
    551552                avail= AV_RL32(tmp);
    552553                if(avail > size){
    553554                    av_log(h, AV_LOG_WARNING, "Part of datagram lost due to insufficient buffer size\n");
     555                    skip = avail - size;
    554556                    avail= size;
    555557                }
    556558
    557559                av_fifo_generic_read(s->fifo, buf, avail, NULL);
     560                if (skip)
     561                    av_fifo_drain(s->fifo, skip);
    558562                return avail;
    559563            }
    560564            else {