[asterisk-commits] tilghman: branch 1.6.0 r169366 - in /branches/1.6.0: ./ apps/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 19 14:08:06 CST 2009


Author: tilghman
Date: Mon Jan 19 14:08:06 2009
New Revision: 169366

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=169366
Log:
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
  ........
................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_userevent.c
    branches/1.6.0/main/manager.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_userevent.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/apps/app_userevent.c?view=diff&rev=169366&r1=169365&r2=169366
==============================================================================
--- branches/1.6.0/apps/app_userevent.c (original)
+++ branches/1.6.0/apps/app_userevent.c Mon Jan 19 14:08:06 2009
@@ -48,15 +48,22 @@
 
 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 @@
 	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;
 }

Modified: branches/1.6.0/main/manager.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/main/manager.c?view=diff&rev=169366&r1=169365&r2=169366
==============================================================================
--- branches/1.6.0/main/manager.c (original)
+++ branches/1.6.0/main/manager.c Mon Jan 19 14:08:06 2009
@@ -870,6 +870,8 @@
  *       initialize the thread local storage key.
  */
 AST_THREADSTORAGE(astman_append_buf);
+AST_THREADSTORAGE(userevent_buf);
+
 /*! \brief initial allocated size for the astman_append_buf */
 #define ASTMAN_APPEND_BUF_INITSIZE   256
 
@@ -2405,18 +2407,15 @@
 static int action_userevent(struct mansession *s, const struct message *m)
 {
 	const char *event = astman_get_header(m, "UserEvent");
-	char body[2048] = "";
-	int x, bodylen = 0;
+	struct ast_str *body = ast_str_thread_get(&userevent_buf, 16);
+	int x;
 	for (x = 0; x < m->hdrcount; x++) {
 		if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
-			ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3);
-			bodylen += strlen(m->headers[x]);
-			ast_copy_string(body + bodylen, "\r\n", 3);
-			bodylen += 2;
-		}
-	}
-
-	manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body);
+			ast_str_append(&body, 0, "%s\r\n", m->headers[x]);
+		}
+	}
+
+	manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body->str);
 	return 0;
 }
 




More information about the asterisk-commits mailing list