[asterisk-commits] rmudgett: branch rmudgett/http_persistent r417247 - in /team/rmudgett/http_pe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 25 20:07:29 CDT 2014


Author: rmudgett
Date: Wed Jun 25 20:07:22 2014
New Revision: 417247

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417247
Log:
Fix ast_realloc() usage.  Add missing va_end().

Modified:
    team/rmudgett/http_persistent/main/http.c
    team/rmudgett/http_persistent/res/res_ari.c

Modified: team/rmudgett/http_persistent/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/http_persistent/main/http.c?view=diff&rev=417247&r1=417246&r2=417247
==============================================================================
--- team/rmudgett/http_persistent/main/http.c (original)
+++ team/rmudgett/http_persistent/main/http.c Wed Jun 25 20:07:22 2014
@@ -916,11 +916,19 @@
 
 		/* insure buffer is large enough +1 */
 		if (content_length + chunk_length >= bufsize) {
-			bufsize *= 2;
-			buf = ast_realloc(buf, bufsize);
-			if (!buf) {
+			char *new_buf;
+
+			/* Increase bufsize until it can handle the expected data. */
+			do {
+				bufsize *= 2;
+			} while (content_length + chunk_length >= bufsize);
+
+			new_buf = ast_realloc(buf, bufsize);
+			if (!new_buf) {
+				ast_free(buf);
 				return NULL;
 			}
+			buf = new_buf;
 		}
 
 		/* read the chunk-data */
@@ -975,6 +983,7 @@
 			/* A blank line ends the chunked-body */
 			break;
 		}
+		ast_log(LOG_NOTICE, "BUGBUG Discarding chunked trailer header: '%s'\n", header_line);
 	}
 
 	request->body_read = 1;

Modified: team/rmudgett/http_persistent/res/res_ari.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/http_persistent/res/res_ari.c?view=diff&rev=417247&r1=417246&r2=417247
==============================================================================
--- team/rmudgett/http_persistent/res/res_ari.c (original)
+++ team/rmudgett/http_persistent/res/res_ari.c Wed Jun 25 20:07:22 2014
@@ -254,6 +254,7 @@
 
 	va_start(ap, message_fmt);
 	message = ast_json_vstringf(message_fmt, ap);
+	va_end(ap);
 	response->message = ast_json_pack("{s: o}",
 					  "message", ast_json_ref(message));
 	response->response_code = response_code;
@@ -882,16 +883,16 @@
 			ast_ari_response_error(&response, 413,
 				"Request Entity Too Large",
 				"Request body too large");
-			break;
+			goto request_failed;
 		case ENOMEM:
 			ast_ari_response_error(&response, 500,
 				"Internal Server Error",
 				"Error processing request");
-			break;
+			goto request_failed;
 		case EIO:
 			ast_ari_response_error(&response, 400,
 				"Bad Request", "Error parsing request body");
-			break;
+			goto request_failed;
 		}
 	}
 	if (get_params == NULL) {
@@ -957,6 +958,7 @@
 		return 0;
 	}
 
+request_failed:
 	/* If you explicitly want to have no content, set message to
 	 * ast_json_null().
 	 */




More information about the asterisk-commits mailing list