Module: sip-router
Branch: master
Commit: fb3a5f7022ebd20fc516b5b8303a0274bda18258
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fb3a5f7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jul 26 14:55:38 2013 +0200
acc: safety check for accounted values not to be NULL
- based on a patch by Federico Cabiddu, FS#327
---
modules/acc/acc.c | 16 ++++++++++------
modules/acc/acc_logic.c | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/modules/acc/acc.c b/modules/acc/acc.c
index d4fd89c..0a563d6 100644
--- a/modules/acc/acc.c
+++ b/modules/acc/acc.c
@@ -241,13 +241,15 @@ int acc_log_request( struct sip_msg *rq)
memcpy(p, log_attrs[i].s, log_attrs[i].len);
p += log_attrs[i].len;
*(p++) = A_EQ_CHR;
- memcpy(p, val_arr[i].s, val_arr[i].len);
- p += val_arr[i].len;
+ if (val_arr[i].s != NULL) {
+ memcpy(p, val_arr[i].s, val_arr[i].len);
+ p += val_arr[i].len;
+ }
}
/* get per leg attributes */
if ( leg_info ) {
- n = legs2strar(leg_info,rq,val_arr+m,int_arr+m,type_arr+m, 1);
+ n = legs2strar(leg_info,rq,val_arr+m,int_arr+m,type_arr+m, 1);
do {
for (i=m; i<m+n; i++) {
if (p+1+log_attrs[i].len+1+val_arr[i].len >= log_msg_end) {
@@ -259,10 +261,12 @@ int acc_log_request( struct sip_msg *rq)
memcpy(p, log_attrs[i].s, log_attrs[i].len);
p += log_attrs[i].len;
*(p++) = A_EQ_CHR;
- memcpy(p, val_arr[i].s, val_arr[i].len);
- p += val_arr[i].len;
+ if (val_arr[i].s != NULL) {
+ memcpy(p, val_arr[i].s, val_arr[i].len);
+ p += val_arr[i].len;
+ }
}
- }while (p!=log_msg_end && (n=legs2strar(leg_info,rq,val_arr+m,
+ } while (p!=log_msg_end && (n=legs2strar(leg_info,rq,val_arr+m,
int_arr+m,type_arr+m,
0))!=0);
}
diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c
index f2efaa7..55b4196 100644
--- a/modules/acc/acc_logic.c
+++ b/modules/acc/acc_logic.c
@@ -220,7 +220,7 @@ int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
if(acc_db_set_table_name(rq, (void*)table, NULL)<0) {
LM_ERR("cannot set table name\n");
return -1;
- }
+ }
env_set_to( rq->to );
env_set_comment((struct acc_param*)comment);
return acc_db_request(rq);