Message ID | 1341964078-22594-1-git-send-email-cody@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 11.7.2012 01:47, cody@linux.vnet.ibm.com wrote: > From: Cody Schafer <cody@linux.vnet.ibm.com> > > For some config options (CONFIG_EXTRA_FIRMWARE, for example), the length > of a config file line can exceed the 1024 byte buffer. > > Switch from fgets to getline to fix. getline() is not a portable function and kconfig is an essential part of kernel build. Could you please change it to a loop over fgets that terminates when the last character is '\n'? Thanks, Michal -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Do we have any strict standards for what is and is not portable? (I'm aware 'getline' was only added to posix ~4 years ago in 2008). -- Cody -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Dne 13.7.2012 20:30, cody napsal(a): > Do we have any strict standards for what is and is not portable? We don't. I only checked the existing userspace code and except for perf, there is no other usage of getline(). > (I'm aware 'getline' was only added to posix ~4 years ago in 2008). Ah, good to know. Nevetheless, let's stay conservative for some more time. Thanks for sending the updated patch, btw. Michal -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 52577f0..175037f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -185,7 +185,8 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) int conf_read_simple(const char *name, int def) { FILE *in = NULL; - char line[1024]; + char *line = NULL; + size_t line_asize = 0; char *p, *p2; struct symbol *sym; int i, def_flags; @@ -247,7 +248,7 @@ load: } } - while (fgets(line, sizeof(line), in)) { + while (getline(&line, &line_asize, in) != -1) { conf_lineno++; sym = NULL; if (line[0] == '#') { @@ -335,6 +336,7 @@ setsym: cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); } } + free(line); fclose(in); if (modules_sym)