diff mbox series

[FFmpeg-devel,v2,3/6] avformat/rtsp: use MAX_URL_SIZE for one line parse

Message ID 1638765904-2521-3-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/6] avformat/rtsp: remove redundant assignment | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Lance Wang Dec. 6, 2021, 4:45 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

The buf is used for one line of sdp parsing, so it's ok to use MAX_URL_SIZE

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/rtsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin Storsjö Dec. 7, 2021, 9:27 a.m. UTC | #1
On Mon, 6 Dec 2021, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> The buf is used for one line of sdp parsing, so it's ok to use MAX_URL_SIZE
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/rtsp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 5cffe0b..3e4a68a 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -709,7 +709,7 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
> {
>     const char *p;
>     int letter, i;
> -    char buf[SDP_MAX_SIZE], *q;
> +    char buf[MAX_URL_SIZE], *q;
>     SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;

No, this is not ok.

For the cases where a SDP is really big (vorbis, theora), then you have 
the majority of the size of the SDP in one line (the format specific fmtp 
line). I just tested generating a RTP stream with libvorbis, and the fmtp 
line ended up at 5194 bytes.

// Martin
Lance Wang Dec. 7, 2021, 10:23 a.m. UTC | #2
On Tue, Dec 07, 2021 at 11:27:32AM +0200, Martin Storsjö wrote:
> On Mon, 6 Dec 2021, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > The buf is used for one line of sdp parsing, so it's ok to use MAX_URL_SIZE
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/rtsp.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index 5cffe0b..3e4a68a 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -709,7 +709,7 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
> > {
> >     const char *p;
> >     int letter, i;
> > -    char buf[SDP_MAX_SIZE], *q;
> > +    char buf[MAX_URL_SIZE], *q;
> >     SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
> 
> No, this is not ok.
> 
> For the cases where a SDP is really big (vorbis, theora), then you have the
> majority of the size of the SDP in one line (the format specific fmtp line).
> I just tested generating a RTP stream with libvorbis, and the fmtp line
> ended up at 5194 bytes.

This makes sense, please ignore the change.

> 
> // Martin
>
diff mbox series

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 5cffe0b..3e4a68a 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -709,7 +709,7 @@  int ff_sdp_parse(AVFormatContext *s, const char *content)
 {
     const char *p;
     int letter, i;
-    char buf[SDP_MAX_SIZE], *q;
+    char buf[MAX_URL_SIZE], *q;
     SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
 
     p = content;