Browse Source

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
Andrei Pelinescu-Onciul 15 years ago
parent
commit
7aea949e1d
1 changed files with 7 additions and 3 deletions
  1. 7 3
      modules/auth/challenge.c

+ 7 - 3
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,