[asterisk-commits] trunk r36892 - /trunk/manager.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 3 17:16:34 MST 2006


Author: tilghman
Date: Mon Jul  3 19:16:33 2006
New Revision: 36892

URL: http://svn.digium.com/view/asterisk?rev=36892&view=rev
Log:
Bug 7472 - Change line terminator for header to be RFC-compliant
Also, check to ensure the memory allocation didn't fail.

Modified:
    trunk/manager.c

Modified: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=36892&r1=36891&r2=36892&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Mon Jul  3 19:16:33 2006
@@ -2169,7 +2169,11 @@
 
 	if (!s) {
 		/* Create new session */
-		s = calloc(1, sizeof(struct mansession));
+		s = ast_calloc(1, sizeof(struct mansession));
+		if (!s) {
+			*status = 500;
+			goto generic_callback_out;
+		}
 		memcpy(&s->sin, requestor, sizeof(s->sin));
 		s->fd = -1;
 		s->waiting_thread = AST_PTHREADT_NULL;
@@ -2203,7 +2207,7 @@
 	memset(&m, 0, sizeof(m));
 	if (s) {
 		char tmp[80];
-		ast_build_string(&c, &len, "Content-type: text/%s\n", contenttype[format]);
+		ast_build_string(&c, &len, "Content-type: text/%s\r\n", contenttype[format]);
 		sprintf(tmp, "%08lx", s->managerid);
 		ast_build_string(&c, &len, "%s\r\n", ast_http_setcookie("mansession_id", tmp, httptimeout, cookie, sizeof(cookie)));
 		if (format == FORMAT_HTML)
@@ -2280,6 +2284,7 @@
 	
 	if (blastaway)
 		destroy_session(s);
+generic_callback_out:
 	if (*status != 200)
 		return ast_http_error(500, "Server Error", NULL, "Internal Server Error (out of memory)\n"); 
 	return retval;



More information about the asterisk-commits mailing list