Module: sip-router
Branch: master
Commit: 11033b05be673593a87afdc2a1d8a2c887fb9ab7
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=11033b0…
Author: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Date: Wed Aug 17 15:00:00 2011 +0300
modules_k/dialog When hash_size was smaller then 1, consider this as a value(1 == 2^0)
The 1<<(n-1) check for the power of two smaller than the given number doesn't
work for n == 0 (undefined behavior),
so values of dlg_hash_size smaller than 1 where not checked correctly.
---
modules_k/dialog/dialog.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c
index d31135a..6711732 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -603,11 +603,18 @@ static int mod_init(void)
return -1;
}
+ /* sanitize dlg_hash_zie */
+ if (dlg_hash_size < 1){
+ LM_WARN("hash_size is smaller "
+ "then 1 -> rounding from %d to 1\n",
+ dlg_hash_size);
+ dlg_hash_size = 1;
+ }
/* initialized the hash table */
for( n=0 ; n<(8*sizeof(n)) ; n++) {
if (dlg_hash_size==(1<<n))
break;
- if (dlg_hash_size<(1<<n)) {
+ if (n && dlg_hash_size<(1<<n)) {
LM_WARN("hash_size is not a power "
"of 2 as it should be -> rounding from %d to %d\n",
dlg_hash_size, 1<<(n-1));