Skip to content

Commit

Permalink
[sipmsgops] fix codec_delete_XX() parsing
Browse files Browse the repository at this point in the history
Issue discovered during OpenSIPS Security Audit 2021,
        by Alfred Farrugia & Sandro Gauci (Enable Security)

GHSA-xj5x-g52f-548h
(cherry picked from commit 8f87c7c)
  • Loading branch information
bogdan-iancu committed Nov 11, 2021
1 parent 290e1ab commit ee115c0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions modules/sipmsgops/codecs.c
Expand Up @@ -347,7 +347,10 @@ static int do_for_all_streams(struct sip_msg* msg, str* str1,str * str2,
}


int delete_sdp_line( struct sip_msg * msg, char * s)
/* deletes a SDP line (from a stream) by giving a pointer within the line.
* The stream is used to safeguard the identification of the line boundries.
*/
int delete_sdp_line( struct sip_msg * msg, char * s, struct sdp_stream_cell *stream)
{
char * start,*end;

Expand All @@ -357,11 +360,11 @@ int delete_sdp_line( struct sip_msg * msg, char * s)
start = s;
end = s;

while(*start != '\n')
while(*start != '\n' && start > stream->body.s)
start--;
start++;

while(*end != '\n')
while(*end != '\n' && end < (stream->body.s+stream->body.len) )
end++;
end++;

Expand Down Expand Up @@ -530,14 +533,14 @@ static int stream_process(struct sip_msg * msg, struct sdp_stream_cell *cell,
{
/* find the full 'a=...' entry */

if( delete_sdp_line( msg, payload->rtp_enc.s) < 0 )
if( delete_sdp_line( msg, payload->rtp_enc.s, cell) < 0 )
{
LM_ERR("Unable to add delete lump for a=\n");
ret = -1;
goto end;
}

if( delete_sdp_line( msg, payload->fmtp_string.s) < 0 )
if( delete_sdp_line( msg, payload->fmtp_string.s, cell) < 0 )
{
LM_ERR("Unable to add delete lump for a=\n");
ret = -1;
Expand Down

0 comments on commit ee115c0

Please sign in to comment.