[SR-Users] msilo patch

Stoyan Mihaylov stoyan.v.mihaylov at gmail.com
Tue Jan 29 17:01:46 CET 2013


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 = 1;
+                       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.



More information about the sr-users mailing list