Skip to content

Commit

Permalink
core: parse via - set len for host/port_str only if there is a value
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Sep 3, 2018
1 parent f872395 commit 8cebf48
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/core/parser/parse_via.c
Expand Up @@ -2073,15 +2073,15 @@ char *parse_via(
break;
case P_HOST:
/*mark end of host*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
state = L_PORT;
break;
case L_PORT: /*eat the spaces*/
case F_PORT:
break;
case P_PORT:
/*end of port */
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
state = L_PARAM;
break;
case L_PARAM: /* eat the space */
Expand Down Expand Up @@ -2131,13 +2131,13 @@ char *parse_via(
break;
case P_HOST:
/*mark end of host*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
saved_state = L_PORT;
state = F_LF;
break;
case P_PORT:
/*end of port */
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
saved_state = L_PARAM;
state = F_LF;
break;
Expand Down Expand Up @@ -2176,13 +2176,13 @@ char *parse_via(
break;
case P_HOST:
/*mark end of host*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
saved_state = L_PORT;
state = F_CR;
break;
case P_PORT:
/*end of port */
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
saved_state = L_PARAM;
state = F_CR;
break;
Expand Down Expand Up @@ -2212,7 +2212,7 @@ char *parse_via(
break;
case P_HOST:
/*mark end of host*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
state = F_PORT;
break;
case L_PORT:
Expand Down Expand Up @@ -2257,13 +2257,13 @@ char *parse_via(
LM_ERR("bad ipv6 reference\n");
goto error;
case P_HOST:
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
state = F_PARAM;
param_start = tmp + 1;
break;
case P_PORT:
/*mark the end*/
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
case L_PORT:
case L_PARAM:
state = F_PARAM;
Expand Down Expand Up @@ -2313,12 +2313,12 @@ char *parse_via(
goto error;
case P_HOST:
/*mark the end*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
state = F_VIA;
break;
case P_PORT:
/*mark the end*/
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
state = F_VIA;
break;
case L_PORT:
Expand Down Expand Up @@ -2363,13 +2363,13 @@ char *parse_via(
goto error;
case P_HOST:
/*mark the end*/
vb->host.len = tmp - vb->host.s;
if(vb->host.s) vb->host.len = tmp - vb->host.s;
state = F_COMMENT;
c_nest++;
break;
case P_PORT:
/*mark the end*/
vb->port_str.len = tmp - vb->port_str.s;
if(vb->port_str.s) vb->port_str.len = tmp - vb->port_str.s;
state = F_COMMENT;
c_nest++;
break;
Expand Down Expand Up @@ -2469,7 +2469,7 @@ char *parse_via(
switch(state) {
case P_IP6HOST:
/*mark the end*/
vb->host.len = (tmp - vb->host.s) + 1; /* include "]" */
if(vb->host.s) vb->host.len = (tmp - vb->host.s) + 1; /* include "]" */
state = L_PORT;
break;
case F_CRLF:
Expand Down

0 comments on commit 8cebf48

Please sign in to comment.