diff --git a/main/http.c b/main/http.c
index 73fb8bc9236e0ca2b8a6d55e8a7264b26baa3fe3..a92c77db903ddcf8b677b16da8e60a5bf5f1ffd5 100644
--- a/main/http.c
+++ b/main/http.c
@@ -601,6 +601,8 @@ void ast_http_uri_unlink_all_with_key(const char *key)
 	AST_RWLIST_UNLOCK(&uris);
 }
 
+#define MAX_POST_CONTENT 1025
+
 /*
  * get post variables from client Request Entity-Body, if content type is
  * application/x-www-form-urlencoded
@@ -633,6 +635,13 @@ struct ast_variable *ast_http_get_post_vars(
 		return NULL;
 	}
 
+	if (content_length > MAX_POST_CONTENT - 1) {
+		ast_log(LOG_WARNING, "Excessively long HTTP content. %d is greater than our max of %d\n",
+				content_length, MAX_POST_CONTENT);
+		ast_http_send(ser, AST_HTTP_POST, 413, "Request Entity Too Large", NULL, NULL, 0, 0);
+		return NULL;
+	}
+
 	buf = ast_malloc(content_length + 1);
 	if (!buf) {
 		return NULL;