Commit 96e9dd14a3b2aab4098503a5999ee2ef42d82da1

Authored by Ben Collins
Committed by Linus Torvalds
1 parent f756d5e256

[PATCH] kconf: Check for eof from input stream.

Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 16 additions and 2 deletions Side-by-side Diff

scripts/kconfig/conf.c
... ... @@ -63,6 +63,20 @@
63 63 }
64 64 }
65 65  
  66 +static char *fgets_check_stream(char *s, int size, FILE *stream)
  67 +{
  68 + char *ret = fgets(s, size, stream);
  69 +
  70 + if (ret == NULL && feof(stream)) {
  71 + printf(_("aborted!\n\n"));
  72 + printf(_("Console input is closed. "));
  73 + printf(_("Run 'make oldconfig' to update configuration.\n\n"));
  74 + exit(1);
  75 + }
  76 +
  77 + return ret;
  78 +}
  79 +
66 80 static void conf_askvalue(struct symbol *sym, const char *def)
67 81 {
68 82 enum symbol_type type = sym_get_type(sym);
... ... @@ -100,7 +114,7 @@
100 114 check_stdin();
101 115 case ask_all:
102 116 fflush(stdout);
103   - fgets(line, 128, stdin);
  117 + fgets_check_stream(line, 128, stdin);
104 118 return;
105 119 case set_default:
106 120 printf("%s\n", def);
... ... @@ -356,7 +370,7 @@
356 370 check_stdin();
357 371 case ask_all:
358 372 fflush(stdout);
359   - fgets(line, 128, stdin);
  373 + fgets_check_stream(line, 128, stdin);
360 374 strip(line);
361 375 if (line[0] == '?') {
362 376 printf("\n%s\n", menu->sym->help ?