Index: main/http.c
===================================================================
--- main/http.c	(revision 378288)
+++ main/http.c	(revision 378289)
@@ -622,6 +622,7 @@
 	int content_length = 0;
 	struct ast_variable *v, *post_vars=NULL, *prev = NULL;
 	char *buf, *var, *val;
+	int res;
 
 	for (v = headers; v; v = v->next) {
 		if (!strcasecmp(v->name, "Content-Type")) {
@@ -634,21 +635,27 @@
 
 	for (v = headers; v; v = v->next) {
 		if (!strcasecmp(v->name, "Content-Length")) {
-			content_length = atoi(v->value) + 1;
+			content_length = atoi(v->value);
 			break;
 		}
 	}
 
-	if (!content_length) {
+	if (content_length <= 0) {
 		return NULL;
 	}
 
-	if (!(buf = alloca(content_length))) {
+	buf = ast_malloc(content_length + 1);
+	if (!buf) {
 		return NULL;
 	}
-	if (!fgets(buf, content_length, ser->f)) {
-		return NULL;
+
+	res = fread(buf, 1, content_length, ser->f);
+	if (res < content_length) {
+		/* Error, distinguishable by ferror() or feof(), but neither
+		 * is good. */
+		goto done;
 	}
+	buf[content_length] = '\0';
 
 	while ((val = strsep(&buf, "&"))) {
 		var = strsep(&val, "=");
@@ -667,6 +674,9 @@
 			prev = v;
 		}
 	}
+	
+done:
+	ast_free(buf);
 	return post_vars;
 }
 
Index: res/res_jabber.c
===================================================================
--- res/res_jabber.c	(revision 378288)
+++ res/res_jabber.c	(revision 378289)
@@ -777,7 +777,7 @@
  */
 static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
 {
-	char *aux = NULL, *parse = NULL;
+	char *parse = NULL;
 	int timeout;
 	int jidlen, resourcelen;
 	struct timeval start;
@@ -894,7 +894,7 @@
 				continue;
 			}
 			found = 1;
-			aux = ast_strdupa(tmp->message);
+			ast_copy_string(buf, tmp->message, buflen);
 			AST_LIST_REMOVE_CURRENT(list);
 			aji_message_destroy(tmp);
 			break;
@@ -919,7 +919,6 @@
 		ast_log(LOG_NOTICE, "Timed out : no message received from %s\n", args.jid);
 		return -1;
 	}
-	ast_copy_string(buf, aux, buflen);
 
 	return 0;
 }

Property changes on: .
___________________________________________________________________
Modified: branch-1.8-merged
   - /branches/1.8:1-357211,357213-357265,357267-357351,357353-357355,357357-357385,357387-357406,357408-357415,357417-357454,357456-357489,357491-357574,357576-357759,357762-357808,357810,357812-357893,357895-357939,357941-357985,357987-358010,358012-358028,358030-358114,358116-358213,358215-358259,358261-358277,358279-358376,358378-358434,358436-358437,358439-358483,358485-358529,358531-358642,358644-358809,358811-358858,358860-358942,358944-358977,358979-359049,359051-359052,359054-359055,359057-359058,359060-359068,359070-359087,359089-359109,359111-359115,359117-359156,359158-359210,359212-359258,359260-359343,359345-359355,359357-359450,359453-359456,359458-359485,359487-359507,359509-359533,359535-359557,359559-359608,359610-359808,359810-359891,359893-360032,360034-360086,360088-360137,360139-360261,360263-360308,360310-360355,360358-360359,360361-360362,360364-360412,360414-360470,360472,360475-360487,360489-360573,360575-360624,360626-360711,360713-360861,360863-360932,360934-360986,360988-361039,361041-361089,361091-361141,361143-361200,361202-361209,361211-361268,361270-361328,361330-361331,361333-361379,361381-361402,361404-361411,361413-361470,361472-361557,361559-361605,361607-361656,361658-361704,361706-361752,361754-361802,361804-361853,361855-361954,361956-361971,361973-362078,362080-362081,362083-362150,362152-362200,362202-362203,362205-362252,362254-362303,362305-362353,362356-362358,362360-362361,362363-362367,362369-362427,362429-362484,362486-362535,362537-362585,362587-362676,362678-362679,362681-362728,362730-362814,362816-362867,362869-362996,362998-363208,363210-363374,363376-363427,363429-363686,363688-363729,363731-363787,363789-363874,363876-363933,363935-363985,363987-364045,364047-364059,364061-364107,364109-364257,364259-364276,364278-364339,364342-364577,364579-364634,364636-364648,364650-364705,364707-364768,364770-364785,364787-364839,364842-364898,364900-364901,364903-365005,365007-365067,365069-365142,365144-365158,365160-365297,365299-365312,365314-365397,365399-365459,365461-365473,365475,365477-365573,365575-365630,365632-365691,365693-365895,365897-365988,365990-366047,366049-366093,366095-366166,366168-366239,366241-366295,366297-366388,366390-366408,366410-366546,366548-366596,366598-366649,366651-366739,366741-366790,366792-366879,366881,366883-366943,366945-367026,367028-367265,367267-367291,367293-367361,367363-367468,367470-367677,367679-367729,367731-367780,367782-367842,367844-367905,367907-367975,367977-367979,367981-368038,368040-368091,368093-368217,368219-368307,368309-368404,368406-368468,368470-368497,368499-368519,368521-368532,368534-368566,368568-368585,368587-368603,368605-368624,368626-368643,368645-368718,368720-368737,368739-368758,368760-368829,368831-368851,368853-368872,368874-368897,368899-368926,368928-369000,369003-369042,369044-369065,369067-369089,369091-369107,369109-369129,369131-369145,369147-369194,369196-369213,369215-369234,369236-369237,369239-369257,369259-369261,369263-369281,369283-369301,369303-369322,369325-369326,369328-369351,369353-369365,369367-369389,369391-369470,369472-369489,369491-369707,369709-369749,369751-369791,369793-369817,369819-369868,369870-369936,369938-369969,369971-369992,369994-370013,370015-370016,370018-370080,370082-370130,370132-370182,370184-370251,370253-370382,370384-370427,370430-370493,370495-370641,370643-370665,370667-370696,370698-370769,370772-370796,370798-370855,370857-370899,370901-370922,370924-370951,370953-370984,370986-370987,370989-371010,371013-371059,371061-371088,371090-371140,371142-371197,371199-371200,371202-371269,371271-371305,371307-371336,371338-371356,371358-371391,371394-371435,371437-371543,371545-371589,371591-371661,371663-371689,371691-371717,371719-371746,371748-371781,371783-371786,371788-371823,371825-371859,371861-371887,371889-371918,371920-371960,371962-372047,372049-372088,372090-372157,372159-372184,372186-372211,372213-372238,372240-372267,372269-372336,372338,372340-372353,372355-372389,372391-372416,372418-372443,372445-372470,372472-372497,372499-372516,372518-372553,372555-372580,372582-372619,372621-372623,372625-372654,372656-372681,372683-372708,372710-372735,372737-372762,372764,372766-372803,372805-372839,372841-372901,372903-372931,372933-372958,372960-373023,373025-373089,373091-373130,373132-373164,373166-373235,373237-373241,373243-373297,373299-373341,373343-373423,373425-373437,373439-373466,373468-373499,373501-373503,373505-373531,373533-373549,373551-373577,373579-373616,373619-373639,373641-373665,373667-373701,373703-373704,373706-373734,373736-373767,373769-373772,373774-373814,373816-373847,373849-373877,373879-373908,373910-373944,373946-373988,373990-374031,374033-374107,374109-374176,374178-374229,374231-374315,374317-374334,374336-374364,374366-374383,374385-374425,374427-374455,374457-374474,374476-374478,374480-374569,374571-374580,374582-374685,374687-374726,374728-374757,374759-374843,375216,375229-375244,375625,376950
   + /branches/1.8:1-357211,357213-357265,357267-357351,357353-357355,357357-357385,357387-357406,357408-357415,357417-357454,357456-357489,357491-357574,357576-357759,357762-357808,357810,357812-357893,357895-357939,357941-357985,357987-358010,358012-358028,358030-358114,358116-358213,358215-358259,358261-358277,358279-358376,358378-358434,358436-358437,358439-358483,358485-358529,358531-358642,358644-358809,358811-358858,358860-358942,358944-358977,358979-359049,359051-359052,359054-359055,359057-359058,359060-359068,359070-359087,359089-359109,359111-359115,359117-359156,359158-359210,359212-359258,359260-359343,359345-359355,359357-359450,359453-359456,359458-359485,359487-359507,359509-359533,359535-359557,359559-359608,359610-359808,359810-359891,359893-360032,360034-360086,360088-360137,360139-360261,360263-360308,360310-360355,360358-360359,360361-360362,360364-360412,360414-360470,360472,360475-360487,360489-360573,360575-360624,360626-360711,360713-360861,360863-360932,360934-360986,360988-361039,361041-361089,361091-361141,361143-361200,361202-361209,361211-361268,361270-361328,361330-361331,361333-361379,361381-361402,361404-361411,361413-361470,361472-361557,361559-361605,361607-361656,361658-361704,361706-361752,361754-361802,361804-361853,361855-361954,361956-361971,361973-362078,362080-362081,362083-362150,362152-362200,362202-362203,362205-362252,362254-362303,362305-362353,362356-362358,362360-362361,362363-362367,362369-362427,362429-362484,362486-362535,362537-362585,362587-362676,362678-362679,362681-362728,362730-362814,362816-362867,362869-362996,362998-363208,363210-363374,363376-363427,363429-363686,363688-363729,363731-363787,363789-363874,363876-363933,363935-363985,363987-364045,364047-364059,364061-364107,364109-364257,364259-364276,364278-364339,364342-364577,364579-364634,364636-364648,364650-364705,364707-364768,364770-364785,364787-364839,364842-364898,364900-364901,364903-365005,365007-365067,365069-365142,365144-365158,365160-365297,365299-365312,365314-365397,365399-365459,365461-365473,365475,365477-365573,365575-365630,365632-365691,365693-365895,365897-365988,365990-366047,366049-366093,366095-366166,366168-366239,366241-366295,366297-366388,366390-366408,366410-366546,366548-366596,366598-366649,366651-366739,366741-366790,366792-366879,366881,366883-366943,366945-367026,367028-367265,367267-367291,367293-367361,367363-367468,367470-367677,367679-367729,367731-367780,367782-367842,367844-367905,367907-367975,367977-367979,367981-368038,368040-368091,368093-368217,368219-368307,368309-368404,368406-368468,368470-368497,368499-368519,368521-368532,368534-368566,368568-368585,368587-368603,368605-368624,368626-368643,368645-368718,368720-368737,368739-368758,368760-368829,368831-368851,368853-368872,368874-368897,368899-368926,368928-369000,369003-369042,369044-369065,369067-369089,369091-369107,369109-369129,369131-369145,369147-369194,369196-369213,369215-369234,369236-369237,369239-369257,369259-369261,369263-369281,369283-369301,369303-369322,369325-369326,369328-369351,369353-369365,369367-369389,369391-369470,369472-369489,369491-369707,369709-369749,369751-369791,369793-369817,369819-369868,369870-369936,369938-369969,369971-369992,369994-370013,370015-370016,370018-370080,370082-370130,370132-370182,370184-370251,370253-370382,370384-370427,370430-370493,370495-370641,370643-370665,370667-370696,370698-370769,370772-370796,370798-370855,370857-370899,370901-370922,370924-370951,370953-370984,370986-370987,370989-371010,371013-371059,371061-371088,371090-371140,371142-371197,371199-371200,371202-371269,371271-371305,371307-371336,371338-371356,371358-371391,371394-371435,371437-371543,371545-371589,371591-371661,371663-371689,371691-371717,371719-371746,371748-371781,371783-371786,371788-371823,371825-371859,371861-371887,371889-371918,371920-371960,371962-372047,372049-372088,372090-372157,372159-372184,372186-372211,372213-372238,372240-372267,372269-372336,372338,372340-372353,372355-372389,372391-372416,372418-372443,372445-372470,372472-372497,372499-372516,372518-372553,372555-372580,372582-372619,372621-372623,372625-372654,372656-372681,372683-372708,372710-372735,372737-372762,372764,372766-372803,372805-372839,372841-372901,372903-372931,372933-372958,372960-373023,373025-373089,373091-373130,373132-373164,373166-373235,373237-373241,373243-373297,373299-373341,373343-373423,373425-373437,373439-373466,373468-373499,373501-373503,373505-373531,373533-373549,373551-373577,373579-373616,373619-373639,373641-373665,373667-373701,373703-373704,373706-373734,373736-373767,373769-373772,373774-373814,373816-373847,373849-373877,373879-373908,373910-373944,373946-373988,373990-374031,374033-374107,374109-374176,374178-374229,374231-374315,374317-374334,374336-374364,374366-374383,374385-374425,374427-374455,374457-374474,374476-374478,374480-374569,374571-374580,374582-374685,374687-374726,374728-374757,374759-374843,375216,375229-375244,375625,376950,378269

