ERRMAND, /* mandatory option not found */
ERRUNKN, /* unknown config key */
ERRSECTION, /* section not found */
+ ERRTOOLONG, /* string too long */
};
/* maximum line length of config file entries */
unsigned int i;
char linebuf[LINE_LEN+1];
char *line = linebuf;
+ int linenum = 0;
pr_debug("%s: section='%s' file='%s'\n", __func__, section, fname);
char wordbuf[LINE_LEN];
char *wordend;
+ linenum++;
if (*line == '#')
continue;
+ /* if line was fetch completely, string ends with '\n' */
+ if (! strchr(line, '\n')) {
+ ulogd_log(ULOGD_ERROR, "line %d too long.\n", linenum);
+ return -ERRTOOLONG;
+ }
+
if (!(wordend = get_word(line, " \t\n[]", (char *) wordbuf)))
continue;
pr_debug("word: \"%s\"\n", wordbuf);
char wordbuf[LINE_LEN];
char *wordend;
+ linenum++;
pr_debug("line read: %s\n", line);
if (*line == '#')
continue;
+ /* if line was fetch completely, string ends with '\n' */
+ if (! strchr(line, '\n')) {
+ ulogd_log(ULOGD_ERROR, "line %d too long.\n", linenum);
+ return -ERRTOOLONG;
+ }
+
if (!(wordend = get_word(line, " =\t\n", (char *) &wordbuf)))
continue;
if (strlen(args) <
CONFIG_VAL_STRING_LEN ) {
strcpy(ce->u.string, args);
- /* FIXME: what if not ? */
+ } else {
+ config_errce = ce;
+ err = -ERRTOOLONG;
+ goto cpf_error;
}
break;
case CONFIG_TYPE_INT:
ulogd_log(ULOGD_ERROR,
"section \"%s\" not found\n", section);
break;
+ case -ERRTOOLONG:
+ if (config_errce->key)
+ ulogd_log(ULOGD_ERROR,
+ "string value too long for key \"%s\"\n",
+ config_errce->key);
+ else
+ ulogd_log(ULOGD_ERROR,
+ "string value is too long\n");
+ break;
}
return 1;
}