diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-19 20:10:13 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-19 20:10:13 +0000 |
commit | a2f4c5acdee39ea7d22f5fe5f919d512aa8ab51f (patch) | |
tree | 273fbf81b5da0a3d28ce3b2ea8295362b27bf267 /apps/app_userevent.c | |
parent | 8059ff2f4f18adc99747ec2959d7c64eda22de9b (diff) |
Merged revisions 169365 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r169365 | tilghman | 2009-01-19 14:05:52 -0600 (Mon, 19 Jan 2009) | 11 lines
Merged revisions 169364 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r169364 | tilghman | 2009-01-19 13:49:25 -0600 (Mon, 19 Jan 2009) | 4 lines
Truncate userevents at the end of a line, when the command exceeds the buffer.
(closes issue #14278)
Reported by: fnordian
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@169368 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_userevent.c')
-rw-r--r-- | apps/app_userevent.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/app_userevent.c b/apps/app_userevent.c index 91d067d54..c7abd3dfe 100644 --- a/apps/app_userevent.c +++ b/apps/app_userevent.c @@ -48,15 +48,22 @@ static char *descrip = static int userevent_exec(struct ast_channel *chan, void *data) { - char *parse, buf[2048] = ""; - int x, buflen = 0; + char *parse; + int x; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(eventname); AST_APP_ARG(extra)[100]; ); + struct ast_str *body = ast_str_create(16); if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n"); + ast_free(body); + return -1; + } + + if (!body) { + ast_log(LOG_WARNING, "Unable to allocate buffer\n"); return -1; } @@ -65,13 +72,11 @@ static int userevent_exec(struct ast_channel *chan, void *data) AST_STANDARD_APP_ARGS(args, parse); for (x = 0; x < args.argc - 1; x++) { - ast_copy_string(buf + buflen, args.extra[x], sizeof(buf) - buflen - 2); - buflen += strlen(args.extra[x]); - ast_copy_string(buf + buflen, "\r\n", 3); - buflen += 2; + ast_str_append(&body, 0, "%s\r\n", args.extra[x]); } - manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, buf); + manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, body->str); + ast_free(body); return 0; } |