[svn-commits] mmichelson: trunk r1158 - /trunk/menuselect.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 13 10:00:03 CDT 2014


Author: mmichelson
Date: Fri Jun 13 09:59:54 2014
New Revision: 1158

URL: http://svnview.digium.com/svn/menuselect?view=rev&rev=1158
Log:
Increase buffer size so that input lines are not truncated.

Specifically, when disabling all res modules, the input line to
menuselect was too small. The buffer has been quadrupled in
size and also uses a heap allocation.

ASTERISK-23830 #close
Reported by Corey Farrell

Review: https://reviewboard.asterisk.org/r/3599


Modified:
    trunk/menuselect.c

Modified: trunk/menuselect.c
URL: http://svnview.digium.com/svn/menuselect/trunk/menuselect.c?view=diff&rev=1158&r1=1157&r2=1158
==============================================================================
--- trunk/menuselect.c (original)
+++ trunk/menuselect.c Fri Jun 13 09:59:54 2014
@@ -1256,7 +1256,8 @@
 static int parse_existing_config(const char *infile)
 {
 	FILE *f;
-	char buf[2048];
+#define PARSE_BUF_SIZE 8192
+	char *buf = NULL;
 	char *category, *parse, *member;
 	int lineno = 0;
 
@@ -1266,7 +1267,13 @@
 		return -1;
 	}
 
-	while (fgets(buf, sizeof(buf), f)) {
+	buf = malloc(PARSE_BUF_SIZE);
+	if (!buf) {
+		fprintf(stderr, "Unable to allocate buffer for reading existing config.\n");
+		exit(1);
+	}
+
+	while (fgets(buf, PARSE_BUF_SIZE, f)) {
 		lineno++;
 
 		if (strlen_zero(buf))
@@ -1309,6 +1316,7 @@
 		}
 	}
 
+	free(buf);
 	fclose(f);
 
 	return 0;




More information about the svn-commits mailing list