diff options
author | Corey Farrell <git@cfware.com> | 2017-12-18 21:12:47 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2017-12-19 16:43:49 -0500 |
commit | d51837a1b91cf8bcbf1e61f26d2e9b140ecc7cdb (patch) | |
tree | a761a408ce381351d17b87668ccef02ca7588b38 /main/manager.c | |
parent | 204dd027dd65125761194ec6a52c02883fd64eb1 (diff) |
CLI: Address multiple issues.
* listen uses the variable `s` for the result from ast_poll() then
overwrites it with the result of accept(). Create a separate variable
poll_result to avoid confusion since ast_poll does not return a file
descriptor.
* Resolve fd leak that would occur if setsockopt failed in listen.
* Reserve an extra byte while processing completion results from remote
daemon. This fixes a bug where completion processing used strstr() on
a string that was not '\0' terminated. This was no risk to the Asterisk
daemon, the bug was only reachable the remote console process.
* Resolve leak in handle_showchan when the channel is not found.
* Multiple leaks and a deadlock in pbx_config CLI completion.
* Fix leaks in "manager show command".
Change-Id: I8f633ceb1714867ae30ef4e421858f77c14485a9
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c index 079dab77f..71d7432a0 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2343,11 +2343,12 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ AST_RWLIST_UNLOCK(&actions); return ret; } - authority = ast_str_alloca(MAX_AUTH_PERM_STRING); if (a->argc < 4) { return CLI_SHOWUSAGE; } + authority = ast_str_alloca(MAX_AUTH_PERM_STRING); + #ifdef AST_XML_DOCS /* setup the titles */ term_color(synopsis_title, "[Synopsis]\n", COLOR_MAGENTA, 0, 40); @@ -2375,6 +2376,22 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ char *seealso = ast_xmldoc_printable(S_OR(cur->seealso, "Not available"), 1); char *privilege = ast_xmldoc_printable(S_OR(auth_str, "Not available"), 1); char *responses = ast_xmldoc_printable("None", 1); + + if (!syntax || !synopsis || !description || !arguments + || !seealso || !privilege || !responses) { + ast_free(syntax); + ast_free(synopsis); + ast_free(description); + ast_free(arguments); + ast_free(seealso); + ast_free(privilege); + ast_free(responses); + ast_cli(a->fd, "Allocation failure.\n"); + AST_RWLIST_UNLOCK(&actions); + + return CLI_FAILURE; + } + ast_cli(a->fd, "%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s", syntax_title, syntax, synopsis_title, synopsis, @@ -2402,6 +2419,14 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ ast_cli(a->fd, "Event: %s\n", cur->final_response->name); print_event_instance(a, cur->final_response); } + + ast_free(syntax); + ast_free(synopsis); + ast_free(description); + ast_free(arguments); + ast_free(seealso); + ast_free(privilege); + ast_free(responses); } else #endif { |