avformat/rtspdec: get rid of the hardcoded max size for sdp
Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
parent
98054e4f01
commit
d782c746a0
|
@ -172,7 +172,7 @@ static int rtsp_read_announce(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
RTSPState *rt = s->priv_data;
|
RTSPState *rt = s->priv_data;
|
||||||
RTSPMessageHeader request = { 0 };
|
RTSPMessageHeader request = { 0 };
|
||||||
char sdp[SDP_MAX_SIZE];
|
char *sdp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = rtsp_read_request(s, &request, "ANNOUNCE");
|
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);
|
rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq);
|
||||||
return AVERROR_OPTION_NOT_FOUND;
|
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 */
|
/* Read SDP */
|
||||||
if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length)
|
if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length)
|
||||||
< request.content_length) {
|
< request.content_length) {
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"Unable to get complete SDP Description in ANNOUNCE\n");
|
"Unable to get complete SDP Description in ANNOUNCE\n");
|
||||||
rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq);
|
rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq);
|
||||||
|
av_free(sdp);
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
}
|
}
|
||||||
sdp[request.content_length] = '\0';
|
sdp[request.content_length] = '\0';
|
||||||
av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp);
|
av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp);
|
||||||
ret = ff_sdp_parse(s, sdp);
|
ret = ff_sdp_parse(s, sdp);
|
||||||
|
av_free(sdp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);
|
rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);
|
||||||
|
|
Loading…
Reference in New Issue