[asterisk-commits] tilghman: trunk r101018 - /trunk/res/res_config_curl.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 29 16:04:15 CST 2008


Author: tilghman
Date: Tue Jan 29 16:04:15 2008
New Revision: 101018

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101018
Log:
Oops, a sizeof error

Modified:
    trunk/res/res_config_curl.c

Modified: trunk/res/res_config_curl.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_config_curl.c?view=diff&rev=101018&r1=101017&r2=101018
==============================================================================
--- trunk/res/res_config_curl.c (original)
+++ trunk/res/res_config_curl.c Tue Jan 29 16:04:15 2008
@@ -61,7 +61,7 @@
 	char *stringp, *pair, *key;
 	int i;
 	struct ast_variable *var=NULL, *prev=NULL;
-	const int EncodeSpecialChars = 1;
+	const int EncodeSpecialChars = 1, bufsize = 64000;
 	char *buffer;
 
 	if (!ast_custom_function_find("CURL")) {
@@ -72,7 +72,7 @@
 	if (!(query = ast_str_create(1000)))
 		return NULL;
 
-	if (!(buffer = ast_malloc(64000))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return NULL;
 	}
@@ -88,7 +88,7 @@
 	va_end(ap);
 
 	ast_str_append(&query, 0, ")}");
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	/* Remove any trailing newline characters */
 	if ((stringp = strchr(buffer, '\r')) || (stringp = strchr(buffer, '\n')))
@@ -131,7 +131,8 @@
 	char buf1[200], buf2[200];
 	const char *newparam, *newval;
 	char *stringp, *line, *pair, *key, *initfield = NULL;
-	int i, EncodeSpecialChars = 1;
+	int i;
+	const int EncodeSpecialChars = 1, bufsize = 256000;
 	struct ast_variable *var=NULL;
 	struct ast_config *cfg=NULL;
 	struct ast_category *cat=NULL;
@@ -145,7 +146,7 @@
 	if (!(query = ast_str_create(1000)))
 		return NULL;
 
-	if (!(buffer = ast_malloc(256000))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return NULL;
 	}
@@ -165,7 +166,7 @@
 	ast_str_append(&query, 0, ")}");
 
 	/* Do the CURL query */
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	if (!(cfg = ast_config_new()))
 		goto exit_multi;
@@ -224,7 +225,7 @@
 	const char *newparam, *newval;
 	char *stringp;
 	int i, rowcount = -1;
-	const int EncodeSpecialChars = 1;
+	const int EncodeSpecialChars = 1, bufsize = 100;
 	char *buffer;
 
 	if (!ast_custom_function_find("CURL")) {
@@ -235,7 +236,7 @@
 	if (!(query = ast_str_create(1000)))
 		return -1;
 
-	if (!(buffer = ast_malloc(100))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return -1;
 	}
@@ -253,7 +254,7 @@
 	va_end(ap);
 
 	ast_str_append(&query, 0, ")}");
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	/* Line oriented output */
 	stringp = buffer;
@@ -290,7 +291,7 @@
 	const char *newparam, *newval;
 	char *stringp;
 	int i, rowcount = -1;
-	const int EncodeSpecialChars = 1;
+	const int EncodeSpecialChars = 1, bufsize = 100;
 	char *buffer;
 
 	if (!ast_custom_function_find("CURL")) {
@@ -301,7 +302,7 @@
 	if (!(query = ast_str_create(1000)))
 		return -1;
 
-	if (!(buffer = ast_malloc(100))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return -1;
 	}
@@ -317,7 +318,7 @@
 	va_end(ap);
 
 	ast_str_append(&query, 0, ")}");
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	stringp = buffer;
 	while (*stringp <= ' ')
@@ -355,7 +356,7 @@
 	const char *newparam, *newval;
 	char *stringp;
 	int i, rowcount = -1;
-	const int EncodeSpecialChars = 1;
+	const int EncodeSpecialChars = 1, bufsize = 100;
 	char *buffer;
 
 	if (!ast_custom_function_find("CURL")) {
@@ -366,7 +367,7 @@
 	if (!(query = ast_str_create(1000)))
 		return -1;
 
-	if (!(buffer = ast_malloc(100))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return -1;
 	}
@@ -384,7 +385,7 @@
 	va_end(ap);
 
 	ast_str_append(&query, 0, ")}");
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	/* Line oriented output */
 	stringp = buffer;
@@ -407,7 +408,8 @@
 	struct ast_str *query;
 	char buf1[200];
 	char *stringp, *line, *pair, *key;
-	int EncodeSpecialChars = 1, last_cat_metric = -1, cat_metric = -1;
+	const int EncodeSpecialChars = 1, bufsize = 256000;
+	int last_cat_metric = -1, cat_metric = -1;
 	struct ast_category *cat=NULL;
 	char *buffer, *cur_cat = "";
 	char *category = "", *var_name = "", *var_val = "";
@@ -421,7 +423,7 @@
 	if (!(query = ast_str_create(1000)))
 		return NULL;
 
-	if (!(buffer = ast_malloc(256000))) {
+	if (!(buffer = ast_malloc(bufsize))) {
 		ast_free(query);
 		return NULL;
 	}
@@ -430,7 +432,7 @@
 	ast_str_set(&query, 0, "${CURL(%s/static?file=%s)}", url, buf1);
 
 	/* Do the CURL query */
-	pbx_substitute_variables_helper(NULL, query->str, buffer, sizeof(buffer));
+	pbx_substitute_variables_helper(NULL, query->str, buffer, bufsize);
 
 	/* Line oriented output */
 	stringp = buffer;




More information about the asterisk-commits mailing list