[sr-dev] git:master: auth: fix pool no. when both nc and otn are enabled

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Oct 15 10:11:34 CEST 2010


Module: sip-router
Branch: master
Commit: 7aea949e1d1101b87d4327a86f026e119cd0ae8b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7aea949e1d1101b87d4327a86f026e119cd0ae8b

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Fri Oct 15 10:09:03 2010 +0200

auth: fix pool no. when both nc and otn are enabled

When both nonce_count and one_time_nonce are enabled in the same
time, the pool number was corrupted leading to crashes.

Reported-by: Alex Balashov  abalashov evaristesys com

---

 modules/auth/challenge.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/auth/challenge.c b/modules/auth/challenge.c
index 1e4dfe6..9bd4ce0 100644
--- a/modules/auth/challenge.c
+++ b/modules/auth/challenge.c
@@ -89,6 +89,7 @@ int get_challenge_hf(struct sip_msg* msg, int stale, str* realm,
 #if defined USE_NC || defined USE_OT_NONCE
 	unsigned int n_id;
 	unsigned char pool;
+	unsigned char pool_flags;
 #endif
 
 	if(!ahf)
@@ -170,23 +171,26 @@ int get_challenge_hf(struct sip_msg* msg, int stale, str* realm,
 		if (nc_enabled || otn_enabled){
 			pool=nid_get_pool();
 			n_id=nid_inc(pool);
+			pool_flags=0;
 #ifdef USE_NC
 			if (nc_enabled){
 				nc_new(n_id, pool);
-				pool|=  NF_VALID_NC_ID;
+				pool_flags|=  NF_VALID_NC_ID;
 			}
 #endif
 #ifdef USE_OT_NONCE
 			if (otn_enabled){
 				otn_new(n_id, pool);
-				pool|= NF_VALID_OT_ID;
+				pool_flags|= NF_VALID_OT_ID;
 			}
 #endif
 		}else{
 			pool=0;
+			pool_flags=0;
 			n_id=0;
 		}
-		if (calc_nonce(p, &l, cfg, t, t + nonce_expire, n_id, pool,
+		if (calc_nonce(p, &l, cfg, t, t + nonce_expire, n_id,
+						pool | pool_flags,
 						&secret1, &secret2, msg) != 0)
 #else  /* USE_NC || USE_OT_NONCE*/
 		if (calc_nonce(p, &l, cfg, t, t + nonce_expire, 




More information about the sr-dev mailing list