Message ID | 1638441459-21819-2-git-send-email-lance.lmwang@gmail.com |
---|---|
State | Accepted |
Commit | d782c746a0d31b48b4484421ab80a472db954bc7 |
Headers | show |
Series | [FFmpeg-devel,v3,1/2] avformat/rtsp: load the sdp file with avio_read_to_bprint() | expand |
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 |
On Thu, 2 Dec 2021, lance.lmwang@gmail.com wrote: > From: Limin Wang <lance.lmwang@gmail.com> > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > --- > libavformat/rtspdec.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) LGTM, thanks! If this was the last use of SDP_MAX_SIZE, I guess this patch could remove the define too? // Martin
On Thu, Dec 02, 2021 at 01:20:00PM +0200, Martin Storsjö wrote: > On Thu, 2 Dec 2021, lance.lmwang@gmail.com wrote: > > > From: Limin Wang <lance.lmwang@gmail.com> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > > --- > > libavformat/rtspdec.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > LGTM, thanks! > > If this was the last use of SDP_MAX_SIZE, I guess this patch could remove > the define too? No, not yet, ff_sdp_parse() use it still(it's used for one line parse, I think it's too big for one line) and av_sdp_create() in rtspenc.c use it also. > > // Martin >
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 0e91e3e..2ada29a 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -172,7 +172,7 @@ static int rtsp_read_announce(AVFormatContext *s) { RTSPState *rt = s->priv_data; RTSPMessageHeader request = { 0 }; - char sdp[SDP_MAX_SIZE]; + char *sdp; int ret; ret = rtsp_read_request(s, &request, "ANNOUNCE"); @@ -185,18 +185,24 @@ static int rtsp_read_announce(AVFormatContext *s) rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq); return AVERROR_OPTION_NOT_FOUND; } - if (request.content_length && request.content_length < sizeof(sdp) - 1) { + if (request.content_length) { + sdp = av_malloc(request.content_length + 1); + if (!sdp) + return AVERROR(ENOMEM); + /* Read SDP */ if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length) < request.content_length) { av_log(s, AV_LOG_ERROR, "Unable to get complete SDP Description in ANNOUNCE\n"); rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq); + av_free(sdp); return AVERROR(EIO); } sdp[request.content_length] = '\0'; av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp); ret = ff_sdp_parse(s, sdp); + av_free(sdp); if (ret) return ret; rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);