1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

lavf/rtmpproto: fix the playpath truncation if the len > 512

fix the playpath truncation if the len > 512

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Found-by: liuwenhuang <liuwenhuang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
Jun Zhao
2019-11-15 19:10:47 +08:00
parent 4fb6ce27f0
commit 487e7e9670

View File

@@ -48,7 +48,6 @@
#endif #endif
#define APP_MAX_LENGTH 1024 #define APP_MAX_LENGTH 1024
#define PLAYPATH_MAX_LENGTH 512
#define TCURL_MAX_LENGTH 1024 #define TCURL_MAX_LENGTH 1024
#define FLASHVER_MAX_LENGTH 64 #define FLASHVER_MAX_LENGTH 64
#define RTMP_PKTDATA_DEFAULT_SIZE 4096 #define RTMP_PKTDATA_DEFAULT_SIZE 4096
@@ -2746,7 +2745,10 @@ reconnect:
} }
if (!rt->playpath) { 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) { if (!rt->playpath) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail; goto fail;
@@ -2763,7 +2765,7 @@ reconnect:
fname[len - 4] = '\0'; fname[len - 4] = '\0';
rt->playpath[0] = 0; rt->playpath[0] = 0;
} }
av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH); av_strlcat(rt->playpath, fname, max_len);
} else { } else {
rt->playpath[0] = '\0'; rt->playpath[0] = '\0';
} }