Skip to content

Commit

Permalink
fixed #2182
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed May 16, 2022
1 parent 915e2cb commit 75b371e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/ietf/rtsp_command.c
Expand Up @@ -540,6 +540,12 @@ GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com)

//copy the body if any
if (!e && com->Content_Length) {
u32 rsp_size = sess->CurrentSize - sess->CurrentPos;
if (rsp_size < com->Content_Length) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTSP] Invalid content length %u - Response was: \n%s\n", com->Content_Length, sess->tcp_buffer+sess->CurrentPos));
e = GF_NON_COMPLIANT_BITSTREAM;
goto exit;
}
com->body = (char *) gf_malloc(sizeof(char) * (com->Content_Length));
memcpy(com->body, sess->tcp_buffer+sess->CurrentPos + BodyStart, com->Content_Length);
}
Expand Down
17 changes: 7 additions & 10 deletions src/ietf/rtsp_common.c
Expand Up @@ -58,7 +58,6 @@ GF_Err gf_rtsp_read_reply(GF_RTSPSession *sess)

void gf_rtsp_get_body_info(GF_RTSPSession *sess, u32 *body_start, u32 *body_size)
{
u32 i;
s32 start;
char *buffer;
char *cl_str;
Expand All @@ -73,23 +72,21 @@ void gf_rtsp_get_body_info(GF_RTSPSession *sess, u32 *body_start, u32 *body_size

//if found add the 2 "\r\n" and parse it
*body_start = start + 4;
*body_size = 0;

//get the content length
cl_str = strstr(buffer, "Content-Length: ");
if (!cl_str) cl_str = strstr(buffer, "Content-length: ");

if (cl_str) {
char val[30];
char *sep;
cl_str += 16;
i = 0;
while (cl_str[i] != '\r') {
val[i] = cl_str[i];
i += 1;
sep = strchr(cl_str, '\r');
if (sep) {
sep[0] = 0;
*body_size = atoi(cl_str);
sep[0] = '\r';
}
val[i] = 0;
*body_size = atoi(val);
} else {
*body_size = 0;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/ietf/rtsp_response.c
Expand Up @@ -398,6 +398,12 @@ GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp)

//copy the body if any
if (!e && rsp->Content_Length) {
u32 rsp_size = sess->CurrentSize - sess->CurrentPos;
if (rsp_size < rsp->Content_Length) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTSP] Invalid content length %u - Response was: \n%s\n", rsp->Content_Length, sess->tcp_buffer+sess->CurrentPos));
e = GF_NON_COMPLIANT_BITSTREAM;
goto exit;
}
rsp->body = (char *)gf_malloc(sizeof(char) * (rsp->Content_Length));
memcpy(rsp->body, sess->tcp_buffer+sess->CurrentPos + BodyStart, rsp->Content_Length);
}
Expand Down

0 comments on commit 75b371e

Please sign in to comment.