Module: sip-router
Branch: master
Commit: 7e4883b0147424ee27c116ce7826858c7ef486f3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7e4883b…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Fri Jan 15 19:45:38 2010 +0100
auth(k): a few whitespace changes, adjust indention
---
modules_k/auth/index.c | 107 ++++++++++++++++++++++++------------------------
modules_k/auth/nonce.c | 7 +--
2 files changed, 56 insertions(+), 58 deletions(-)
diff --git a/modules_k/auth/index.c b/modules_k/auth/index.c
index ebf1540..bbe7c2f 100644
--- a/modules_k/auth/index.c
+++ b/modules_k/auth/index.c
@@ -140,60 +140,59 @@ int is_nonce_index_valid(int index)
{
/* if greater than MAX_NONCE_INDEX ->error */
if(index>= MAX_NONCE_INDEX ) {
- LM_ERR("index greater than buffer length\n");
- return 0;
- }
-
- lock_get(nonce_lock);
-
- /* if in the first 30 seconds */
- if(sec_monit[*second]== -1)
- {
- if(index>= *next_index)
- {
- LM_DBG("index out of range\n");
- lock_release(nonce_lock);
- return 0;
- }
- else
- {
- set_buf_bit(index);
- lock_release(nonce_lock);
- return 1;
- }
- }
-
- /* check if right interval */
- if(*next_index < sec_monit[*second])
- {
- if(!(index>= sec_monit[*second] || index<= *next_index))
- {
- LM_DBG("index out of the permitted interval\n");
- goto error;
- }
- }
- else
- {
- if(!(index >= sec_monit[*second] && index<=*next_index))
- {
- LM_DBG("index out of the permitted interval\n");
- goto error;
- }
- }
-
- /* check if the first time used */
- if(check_buf_bit(index))
- {
- LM_DBG("nonce already used\n");
- goto error;
- }
-
- set_buf_bit(index);
- lock_release(nonce_lock);
- return 1;
+ LM_ERR("index greater than buffer length\n");
+ return 0;
+ }
-error:
- lock_release(nonce_lock);
- return 0;
+ lock_get(nonce_lock);
+ /* if in the first 30 seconds */
+ if(sec_monit[*second]== -1)
+ {
+ if(index>= *next_index)
+ {
+ LM_DBG("index out of range\n");
+ lock_release(nonce_lock);
+ return 0;
+ }
+ else
+ {
+ set_buf_bit(index);
+ lock_release(nonce_lock);
+ return 1;
+ }
+ }
+
+ /* check if right interval */
+ if(*next_index < sec_monit[*second])
+ {
+ if(!(index>= sec_monit[*second] || index<= *next_index))
+ {
+ LM_DBG("index out of the permitted interval\n");
+ goto error;
+ }
+ }
+ else
+ {
+ if(!(index >= sec_monit[*second] && index<=*next_index))
+ {
+ LM_DBG("index out of the permitted interval\n");
+ goto error;
+ }
+ }
+
+ /* check if the first time used */
+ if(check_buf_bit(index))
+ {
+ LM_DBG("nonce already used\n");
+ goto error;
+ }
+
+ set_buf_bit(index);
+ lock_release(nonce_lock);
+ return 1;
+
+error:
+ lock_release(nonce_lock);
+ return 0;
}
diff --git a/modules_k/auth/nonce.c b/modules_k/auth/nonce.c
index 4118c7a..b9e5f5e 100644
--- a/modules_k/auth/nonce.c
+++ b/modules_k/auth/nonce.c
@@ -164,7 +164,7 @@ int check_nonce(str* _nonce, str* _secret)
{
int expires;
char non[NONCE_LEN + 1];
- int index = 0;
+ int index = 0;
if (_nonce->s == 0) {
return -1; /* Invalid nonce */
@@ -178,13 +178,12 @@ int check_nonce(str* _nonce, str* _secret)
if(nonce_reuse==0)
index = get_nonce_index(_nonce);
- calc_nonce(non, expires, index, _secret);
+ calc_nonce(non, expires, index, _secret);
-
LM_DBG("comparing [%.*s] and [%.*s]\n",
_nonce->len, ZSW(_nonce->s),
((nonce_reuse==0)?NONCE_LEN:NONCE_LEN-8), non);
- if (!memcmp(non, _nonce->s, _nonce->len)) {
+ if (!memcmp(non, _nonce->s, _nonce->len)) {
return 0;
}
return 2;