diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-19 19:49:25 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-01-19 19:49:25 +0000 |
commit | cdb156f197e4485e440828147ca18bb30588e170 (patch) | |
tree | b9bab2a9153e532199b61b4ba90d66d93c457a98 /apps | |
parent | db4dcb58ab0dc1eb89582bf55a67a2d35ccf9267 (diff) |
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.4@169364 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_userevent.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/app_userevent.c b/apps/app_userevent.c index df7bc58a7..dd8000376 100644 --- a/apps/app_userevent.c +++ b/apps/app_userevent.c @@ -59,7 +59,7 @@ static int userevent_exec(struct ast_channel *chan, void *data) { struct ast_module_user *u; char *parse, buf[2048] = ""; - int x, buflen = 0; + int x, buflen = 0, xlen; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(eventname); AST_APP_ARG(extra)[100]; @@ -77,8 +77,13 @@ 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]); + /* Stop once a header comes up that exceeds our buffer. */ + if (sizeof(buf) <= buflen + (xlen = strlen(args.extra[x])) + 3) { + ast_log(LOG_WARNING, "UserEvent exceeds our buffer length! Truncating.\n"); + break; + } + ast_copy_string(buf + buflen, args.extra[x], sizeof(buf) - buflen - 3); + buflen += xlen; ast_copy_string(buf + buflen, "\r\n", 3); buflen += 2; } |