[sr-dev] msilio - m_dump() patch

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 5 22:44:29 CET 2013


Thanks for reporting, it has to be fixed without allocating an useless 
byte. I will look at it soon.

Cheers,
Daniel

On 2/5/13 5:45 PM, Stoyan Mihaylov wrote:
> When I used, last versions from git, I got error and crash of kamailo
> using m_dump.
> I got latest version from git, and I made one patch:
>
> diff --git a/modules/msilo/msilo.c b/modules/msilo/msilo.c
> index 209b309..4bda8fa 100644
> --- a/modules/msilo/msilo.c
> +++ b/modules/msilo/msilo.c
> @@ -1125,8 +1125,16 @@ static int m_dump(struct sip_msg* msg, str* owner_s)
>                          memcpy(tmp_extra_hdrs.s, extra_hdrs_str.s,
> extra_hdrs_str.len);
>                          memcpy(tmp_extra_hdrs.s+extra_hdrs_str.len,
> str_vals[4].s, str_vals[4].len);
>                  } else {
> -                       tmp_extra_hdrs.len = 0;
> -                       tmp_extra_hdrs.s = "";
> +                       tmp_extra_hdrs.len = 0;
> +                       if ((tmp_extra_hdrs.s = pkg_malloc(1)) == NULL)
> +                       {
> +                               LM_ERR("Out of pkg memory");
> +                               if (msilo_dbf.free_result(db_con, db_res) < 0)
> +                                       LM_ERR("failed to free the
> query result\n");
> +                               msg_list_set_flag(ml, mid, MS_MSG_ERRO);
> +                               goto error;
> +                       }
> +                       tmp_extra_hdrs.s[0]='\x0';
>                  }
>                  hdr_str.len = 1024;
>                  if(m_build_headers(&hdr_str, str_vals[3] /*ctype*/,
>
>
> The problem is:
> tmp_extra_hdrs.s = "";
> and consequent
> pkg_free(tmp_extra_hdrs.s);
>
> As I see, there are couple of ways to solve problem, one of them is
> setting tmp_extra_hdrs.s = 0; but then we have warnings, or setting
> tmp_extra_hdrs.s = 0;
> and check before pkg_free, but pkg_free is used on couple of places.
> I am not sure what is the best way to report bugs and offer patches.
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, April 16-17, 2013, Berlin
  - http://conference.kamailio.com -




More information about the sr-dev mailing list