[FFmpeg-devel] [PATCH 1/5] avformat/rtsp: make use of avio_get_str() to load the sdp

Martin Storsjö martin at martin.st
Wed Dec 1 15:55:37 EET 2021


On Wed, 1 Dec 2021, lance.lmwang at gmail.com wrote:

> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavformat/rtsp.c | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index e6a4993..ec8be8b 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2369,11 +2369,29 @@ static void append_source_addrs(char *buf, int size, const char *name,
>         av_strlcatf(buf, size, ",%s", addrs[i]->addr);
> }
>
> +static char *read_sdp_str(AVIOContext *pb, int size)
> +{
> +    int n;
> +    char *str;
> +
> +    if (size < 0 || size == INT_MAX)
> +        return NULL;
> +
> +    str = av_malloc(size + 1);
> +    if (!str)
> +        return NULL;
> +    n = avio_get_str(pb, size, str, size + 1);
> +    if (n < size)
> +        avio_skip(pb, size - n);

What? Why do you want to skip past data in the input? Size here is just a 
random static upper limit of how large an SDP file would be.

This patch totally lacks a motivation of why you want to do this.

// Martin



More information about the ffmpeg-devel mailing list