diff options
author | Russell Bryant <russell@russellbryant.com> | 2007-01-23 21:38:31 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2007-01-23 21:38:31 +0000 |
commit | 8137080816f903ad6fd01a98df948b01b40e5804 (patch) | |
tree | a36c369f65298ab7c52b72ffce8cec24309cabdb | |
parent | 80435b54a596adf02e5c4fb422543bafb700c125 (diff) |
Merged revisions 51750 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r51750 | russell | 2007-01-23 15:33:15 -0600 (Tue, 23 Jan 2007) | 4 lines
When traversing the list of manager actions, the iterator needs to be
initialized to the list head *after* locking the list. Also, lock the actions
list in one place it is being accessed where it was not being done.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/manager.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/main/manager.c b/main/manager.c index f7276a603..8144ccead 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2076,18 +2076,18 @@ static int process_message(struct mansession *s, const struct message *m) astman_send_error(s, m, "Permission denied"); return 0; } - /* XXX should we protect the list navigation ? */ + ast_mutex_lock(&actionlock); for (tmp = first_action ; tmp; tmp = tmp->next) { - if (!strcasecmp(action, tmp->action)) { - if ((s->writeperm & tmp->authority) == tmp->authority) { - if (tmp->func(s, m)) /* error */ - return -1; - } else { - astman_send_error(s, m, "Permission denied"); - } - break; - } + if (strcasecmp(action, tmp->action)) + continue; + if ((s->writeperm & tmp->authority) == tmp->authority) { + if (tmp->func(s, m)) /* error */ + return -1; + } else + astman_send_error(s, m, "Permission denied"); + break; } + ast_mutex_unlock(&actionlock); if (!tmp) astman_send_error(s, m, "Invalid/unknown command. Use Action: ListCommands to show available commands."); if (ret) @@ -2389,7 +2389,7 @@ int __manager_event(int category, const char *event, */ int ast_manager_unregister(char *action) { - struct manager_action *cur = first_action, *prev = first_action; + struct manager_action *cur, *prev; ast_mutex_lock(&actionlock); for (cur = first_action, prev = NULL; cur; prev = cur, cur = cur->next) { |