diff options
author | Russell Bryant <russell@russellbryant.com> | 2009-02-15 20:56:27 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2009-02-15 20:56:27 +0000 |
commit | ca9d3b8ac9ca191ff1ceb04cacb17ca527cf7bea (patch) | |
tree | 13dfce7ac8e12b611f57a934e3721d255bb109e8 /channels | |
parent | cbe45a6e0682c11a6ee0e193f6ba86f9c7909a35 (diff) |
Fix a number of problems with ast_sched_report().
1) It had numerous coding guidelines violations with regards to formatting.
2) It allocated memory using ast_calloc() that was never freed.
3) It didn't check for failure from the allocation.
4) It used sprintf() and strcat() to build the result, doing zero checking to
prevent writing past the end of the provided buffer.
The function also lacks API documentation, but that has not been addressed in
this commit.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@175829 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 686496bee..0742c3010 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -14631,7 +14631,7 @@ static char *sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args static char *sip_show_sched(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - char cbuf[2256]; + struct ast_str *cbuf; struct ast_cb_names cbnames = {9, { "retrans_pkt", "__sip_autodestruct", "expire_register", @@ -14661,9 +14661,13 @@ static char *sip_show_sched(struct ast_cli_entry *e, int cmd, struct ast_cli_arg case CLI_GENERATE: return NULL; } + + cbuf = ast_str_alloca(2048); + ast_cli(a->fd, "\n"); - ast_sched_report(sched, cbuf, sizeof(cbuf), &cbnames); - ast_cli(a->fd, "%s", cbuf); + ast_sched_report(sched, &cbuf, &cbnames); + ast_cli(a->fd, "%s", cbuf->str); + return CLI_SUCCESS; } |