aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-13 20:18:30 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-08-13 20:18:30 +0000
commit1757c35048b69ea298995eefd6adced2f5056843 (patch)
treedde58b7b074681090c8d75e266ddacf0ec83f003
parentf4f8dbcd026dfa68554ccd78ecc4072ad7763cf5 (diff)
Release the pvt lock before calling find_peer in register_verify to avoid a
deadlock. Also, remove some unnecessary locking in auth_fail that was only done recursively. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79276 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_iax2.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 0080384be..1ad1dc9a9 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -5063,10 +5063,11 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
}
/* SLD: first call to lookup peer during registration */
+ ast_mutex_unlock(&iaxsl[callno]);
p = find_peer(peer, 1);
-
- if (!p) {
- if (authdebug)
+ ast_mutex_lock(&iaxsl[callno]);
+ if (!p || !iaxs[callno]) {
+ if (authdebug && !p)
ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(sin->sin_addr));
return -1;
}
@@ -5173,8 +5174,8 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
+
return 0;
-
}
static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct sockaddr_in *sin, aes_encrypt_ctx *ecx, aes_decrypt_ctx *dcx)
@@ -5909,7 +5910,6 @@ static int auth_fail(int callno, int failcode)
{
/* Schedule sending the authentication failure in one second, to prevent
guessing */
- ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
iaxs[callno]->authfail = failcode;
if (delayreject) {
@@ -5919,7 +5919,6 @@ static int auth_fail(int callno, int failcode)
} else
auth_reject((void *)(long)callno);
}
- ast_mutex_unlock(&iaxsl[callno]);
return 0;
}
@@ -7618,10 +7617,18 @@ retryowner2:
if (delayreject)
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
if (register_verify(fr->callno, &sin, &ies)) {
+ if (!iaxs[fr->callno]) {
+ ast_mutex_unlock(&iaxsl[fr->callno]);
+ return 1;
+ }
/* Send delayed failure */
auth_fail(fr->callno, IAX_COMMAND_REGREJ);
break;
}
+ if (!iaxs[fr->callno]) {
+ ast_mutex_unlock(&iaxsl[fr->callno]);
+ return 1;
+ }
if ((ast_strlen_zero(iaxs[fr->callno]->secret) && ast_strlen_zero(iaxs[fr->callno]->inkeys)) ||
ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_AUTHENTICATED | IAX_STATE_UNCHANGED)) {
if (f.subclass == IAX_COMMAND_REGREL)