Module: sip-router
Branch: 3.1
Commit: 8464b29cbffb17b810cc7f3f4f459e754bc0e4ed
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8464b29cbffb17b810cc7f3f4f459e754bc0e4ed

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Tue Apr 12 10:19:38 2011 +0200

acc(k): safety check for empty db_url

- if db_url is provided as empty string, disable db accounting
- if db_url is not provided, db acc flags are set to -1 instead
  of 0 to avoid conflict with usage in config of flag 0
- reported by Francesco Castellano
(cherry picked from commit de2015d507cdd40502160070a096aa3fb6754f55)

---

 modules_k/acc/acc_mod.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules_k/acc/acc_mod.c b/modules_k/acc/acc_mod.c
index ee9336e..cd7b8f4 100644
--- a/modules_k/acc/acc_mod.c
+++ b/modules_k/acc/acc_mod.c
@@ -360,8 +360,13 @@ static int mod_init( void )
                return -1;
 
 #ifdef SQL_ACC
-       if (db_url.s)
+       if (db_url.s) {
                db_url.len = strlen(db_url.s);
+               if(db_url.len<=0) {
+                       db_url.s = NULL;
+                       db_url.len = 0;
+               }
+       }
        db_table_acc.len = strlen(db_table_acc.s);
        db_table_mc.len = strlen(db_table_mc.s);
        acc_method_col.len = strlen(acc_method_col.s);
@@ -471,8 +476,10 @@ static int mod_init( void )
                        return -1;
                }
        } else {
-               db_flag = 0;
-               db_missed_flag = 0;
+               db_url.s = NULL;
+               db_url.len = 0;
+               db_flag = -1;
+               db_missed_flag = -1;
        }
 #endif
 
@@ -503,8 +510,8 @@ static int mod_init( void )
                }
        } else {
                radius_config = 0;
-               radius_flag = 0;
-               radius_missed_flag = 0;
+               radius_flag = -1;
+               radius_missed_flag = -1;
        }
 #endif
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to