Module: sip-router Branch: 3.1 Commit: 18881421102eaac97c85d84cbbd1597c3f342d23 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=18881421...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Timo Reimann timo.reimann@1und1.de 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. (cherry picked from commit 11033b05be673593a87afdc2a1d8a2c887fb9ab7)
---
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 2c63d87..38a30b5 100644 --- a/modules_k/dialog/dialog.c +++ b/modules_k/dialog/dialog.c @@ -559,11 +559,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));