[svn-commits] dlee: branch dlee/ASTERISK-22685-json-body r402386 - /team/dlee/ASTERISK-2268...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 1 16:27:04 CDT 2013


Author: dlee
Date: Fri Nov  1 16:27:03 2013
New Revision: 402386

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402386
Log:
Moved POST error checking to the post-body branch

Modified:
    team/dlee/ASTERISK-22685-json-body/main/http.c
    team/dlee/ASTERISK-22685-json-body/main/manager.c

Modified: team/dlee/ASTERISK-22685-json-body/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/main/http.c?view=diff&rev=402386&r1=402385&r2=402386
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/main/http.c (original)
+++ team/dlee/ASTERISK-22685-json-body/main/http.c Fri Nov  1 16:27:03 2013
@@ -682,12 +682,8 @@
 {
 	int content_length = 0;
 	struct ast_variable *v, *post_vars=NULL, *prev = NULL;
-	char *var, *val;
-	RAII_VAR(char *, buf, NULL, ast_free_ptr);
+	char *buf, *var, *val;
 	int res;
-
-	/* Use errno to distinguish errors from no params */
-	errno = 0;
 
 	for (v = headers; v; v = v->next) {
 		if (!strcasecmp(v->name, "Content-Type")) {
@@ -710,25 +706,22 @@
 	}
 
 	if (content_length > MAX_POST_CONTENT - 1) {
-		ast_log(LOG_WARNING,
-			"Excessively long HTTP content. (%d > %d)\n",
-			content_length, MAX_POST_CONTENT);
-		errno = EFBIG;
+		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) {
-		/* malloc sets errno to ENOMEM */
 		return NULL;
 	}
 
 	res = fread(buf, 1, content_length, ser->f);
 	if (res < content_length) {
 		/* Error, distinguishable by ferror() or feof(), but neither
-		 * is good. Treat either one as I/O error */
-		errno = EIO;
-		return NULL;
+		 * is good. */
+		goto done;
 	}
 	buf[content_length] = '\0';
 
@@ -750,6 +743,8 @@
 		}
 	}
 
+done:
+	ast_free(buf);
 	return post_vars;
 }
 

Modified: team/dlee/ASTERISK-22685-json-body/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22685-json-body/main/manager.c?view=diff&rev=402386&r1=402385&r2=402386
==============================================================================
--- team/dlee/ASTERISK-22685-json-body/main/manager.c (original)
+++ team/dlee/ASTERISK-22685-json-body/main/manager.c Fri Nov  1 16:27:03 2013
@@ -6723,20 +6723,6 @@
 		params = ast_http_get_post_vars(ser, headers);
 	}
 
-	if (!params) {
-		switch (errno) {
-		case EFBIG:
-			ast_http_send(ser, AST_HTTP_POST, 413, "Request Entity Too Large", NULL, NULL, 0, 0);
-			break;
-		case ENOMEM:
-			ast_http_send(ser, AST_HTTP_POST, 500, "Internal Server Error", NULL, NULL, 0, 0);
-			break;
-		case EIO:
-			ast_http_send(ser, AST_HTTP_POST, 400, "Bad Request", NULL, NULL, 0, 0);
-			break;
-		}
-	}
-
 	for (v = params; v && m.hdrcount < ARRAY_LEN(m.headers); v = v->next) {
 		hdrlen = strlen(v->name) + strlen(v->value) + 3;
 		m.headers[m.hdrcount] = ast_malloc(hdrlen);




More information about the svn-commits mailing list