diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-15 20:56:27 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-02-15 20:56:27 +0000 |
commit | 3714d9820fda685c1602606bb1209d79a387632a (patch) | |
tree | 13dfce7ac8e12b611f57a934e3721d255bb109e8 /channels | |
parent | 413dabc747b48fec4e76f913b772904e3f21cae3 (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: http://svn.digium.com/svn/asterisk/trunk@175829 f38db490-d61c-443f-a65b-d21fe96a405b
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; } |