Skip to content

Commit

Permalink
{ip.matches} transformation: Fix pkg memory leak
Browse files Browse the repository at this point in the history
Many thanks to Callum Guy for providing helpful data on this bug!

(cherry picked from commit 1c4fa53)
  • Loading branch information
liviuchircu committed Jan 20, 2020
1 parent 41e03b7 commit 7b9239d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions transformations.c
Expand Up @@ -1681,7 +1681,7 @@ int tr_eval_ip(struct sip_msg *msg, tr_param_t *tp,int subtype,
str inet6 = str_init("INET6");
struct hostent *server;
struct ip_addr ip;
unsigned int len;
unsigned int len, rc;
struct net *mask;
pv_value_t v;
str sv;
Expand Down Expand Up @@ -1876,8 +1876,12 @@ int tr_eval_ip(struct sip_msg *msg, tr_param_t *tp,int subtype,
val->rs.len,val->rs.s);
goto error;
}

mask = mk_net_bitlen(p_ip, len);
switch ( matchnet( &ip, mask) ) {
rc = matchnet(&ip, mask);
pkg_free(mask);

switch (rc) {
case 1: /* matches */
val->ri = 1; break;
case 0: /* does not matches */
Expand Down

0 comments on commit 7b9239d

Please sign in to comment.