Skip to content

Commit

Permalink
parse_via_param(): Fix out-of-bounds read edge-case (OSS-Fuzz)
Browse files Browse the repository at this point in the history
Similar to 5e9f72d, but for the parse_via_param() function.

Severity: Low
Fixes OSS-Fuzz#53080

(cherry picked from commit 6135ff0)
  • Loading branch information
liviuchircu committed Nov 8, 2022
1 parent 4ba077c commit 592694b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion parser/parse_via.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static /*inline*/ char* parse_via_param(char* p, char* end,

find_value:
tmp++;
for(;*tmp;tmp++){
for(;tmp<end;tmp++){
switch(*tmp){
case ' ':
case '\t':
Expand Down Expand Up @@ -909,6 +909,9 @@ static /*inline*/ char* parse_via_param(char* p, char* end,
goto parse_error;
}
break;
case '\0':
break;

default:
switch(state){
case F_VALUE:
Expand Down
8 changes: 5 additions & 3 deletions parser/test/test_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,18 @@ static const struct tts {
/* test for read overflow on Via header (the @end pointer) */
"Q e M\nV:SIP/2.0 /1P 4rr;TT;TT;TT;TT;TT;TT;T\xd2;TT;",
-1,
}, {
/* test for read overflow on Via header param (the @end pointer) */
"A !\nV:SIP/2.0/? M;recEIVeD\n ",
-1,
},

{"\0", 0},
};

void test_parse_msg(void)
{
int i;

for (i = 0; tset[i].tmsg[0]; i++) {
for (i = 0; i < sizeof tset/sizeof *tset; i++) {
struct sip_msg msg;

memset(&msg, 0, sizeof msg);
Expand Down

0 comments on commit 592694b

Please sign in to comment.