#define REQURI_LEN 1024
#define CAPTURE_LEN 64
+// maximum line size when parsing config
+#ifndef LINESIZE
+#define LINESIZE 2048
+#endif
+
// max # args on a configuration line
-#define MAX_LINE_ARGS 40
+#define MAX_LINE_ARGS 64
// max # of added headers per request
#define MAX_NEWHDR 10
*/
int readcfgfile(const char *file)
{
- char thisline[256];
- char *line;
+ char thisline[LINESIZE];
FILE *f;
int linenum = 0;
- char *end;
- char *args[MAX_LINE_ARGS + 1];
- int arg;
int cfgerr = 0;
int confsect = CFG_NONE;
init_default_instance();
- while (fgets(line = thisline, sizeof(thisline), f) != NULL) {
+ while (fgets(thisline, sizeof(thisline), f) != NULL) {
+ int arg;
+ char *end;
+ char *args[MAX_LINE_ARGS + 1];
+ char *line = thisline;
+
linenum++;
end = line + strlen(line);
+ if (end-line == sizeof(thisline)-1 && *(end-1) != '\n') {
+ /* Check if we reached the limit and the last char is not \n.
+ * Watch out for the last line without the terminating '\n'!
+ */
+ Alert("parsing [%s:%d]: line too long, limit: %d.\n",
+ file, linenum, sizeof(thisline)-1);
+ return -1;
+ }
+
/* skip leading spaces */
while (isspace((unsigned char)*line))
line++;
}
else if (isspace((unsigned char)*line)) {
/* a non-escaped space is an argument separator */
- *line++ = 0;
+ *line++ = '\0';
while (isspace((unsigned char)*line))
line++;
args[++arg] = line;