Module: sip-router
Branch: master
Commit: 27a338bb2d0b3665054c1b5bbc6a2832b15e0206
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=27a338b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu May 3 12:15:49 2012 +0200
msilo(k): avoid potential pkg_malloc(0) if no extra hdrs are available
---
modules_k/msilo/msilo.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/modules_k/msilo/msilo.c b/modules_k/msilo/msilo.c
index 2680af4..209b309 100644
--- a/modules_k/msilo/msilo.c
+++ b/modules_k/msilo/msilo.c
@@ -1112,17 +1112,22 @@ static int m_dump(struct sip_msg* msg, str* owner_s)
}
tmp_extra_hdrs.len = extra_hdrs_str.len+str_vals[4].len;
- if ((tmp_extra_hdrs.s = pkg_malloc(tmp_extra_hdrs.len)) == NULL)
+ if(tmp_extra_hdrs.len>0)
{
- 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;
+ if ((tmp_extra_hdrs.s = pkg_malloc(tmp_extra_hdrs.len)) == 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;
+ }
+ 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 = "";
}
- 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);
-
hdr_str.len = 1024;
if(m_build_headers(&hdr_str, str_vals[3] /*ctype*/,
str_vals[0]/*from*/, rtime /*Date*/,