diff mbox

[FFmpeg-devel] lavf/rtmpproto: fix the playpath truncation if the len > 512

Message ID 1573818393-15645-1-git-send-email-mypopydev@gmail.com
State Accepted
Commit 487e7e9670032465e1850d54fd58c5248aa50be9
Headers show

Commit Message

Jun Zhao Nov. 15, 2019, 11:46 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

fix the playpath truncation if the len > 512

Found-by: liuwenhuang <liuwenhuang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/rtmpproto.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Nov. 16, 2019, 8:05 p.m. UTC | #1
On Fri, Nov 15, 2019 at 07:46:33PM +0800, Jun Zhao wrote:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> fix the playpath truncation if the len > 512
> 
> Found-by: liuwenhuang <liuwenhuang@tencent.com>
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/rtmpproto.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)

LGTM

thx

[...]
mypopy@gmail.com Nov. 18, 2019, 6:39 a.m. UTC | #2
On Sun, Nov 17, 2019 at 4:05 AM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Fri, Nov 15, 2019 at 07:46:33PM +0800, Jun Zhao wrote:
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > fix the playpath truncation if the len > 512
> >
> > Found-by: liuwenhuang <liuwenhuang@tencent.com>
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/rtmpproto.c |    8 +++++---
> >  1 files changed, 5 insertions(+), 3 deletions(-)
>
> LGTM
>
> thx
>
Pushed, thx
diff mbox

Patch

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 42c6b94..5274993 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -48,7 +48,6 @@ 
 #endif
 
 #define APP_MAX_LENGTH 1024
-#define PLAYPATH_MAX_LENGTH 512
 #define TCURL_MAX_LENGTH 1024
 #define FLASHVER_MAX_LENGTH 64
 #define RTMP_PKTDATA_DEFAULT_SIZE 4096
@@ -2746,7 +2745,10 @@  reconnect:
     }
 
     if (!rt->playpath) {
-        rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH);
+        int max_len = 1;
+        if (fname)
+            max_len = strlen(fname) + 5; // add prefix "mp4:"
+        rt->playpath = av_malloc(max_len);
         if (!rt->playpath) {
             ret = AVERROR(ENOMEM);
             goto fail;
@@ -2763,7 +2765,7 @@  reconnect:
                     fname[len - 4] = '\0';
                 rt->playpath[0] = 0;
             }
-            av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH);
+            av_strlcat(rt->playpath, fname, max_len);
         } else {
             rt->playpath[0] = '\0';
         }