summaryrefslogtreecommitdiff
path: root/scripts/kconfig/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r--scripts/kconfig/conf.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index a7b44cd8ae14..fe8ba09b0039 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -297,9 +297,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
line[1] = 0;
if (!sym_is_changeable(sym)) {
- printf("%s\n", def);
- line[0] = '\n';
- line[1] = 0;
+ printf("%s\n", def ?: "");
return 0;
}
@@ -307,7 +305,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
case oldconfig:
case syncconfig:
if (sym_has_value(sym)) {
- printf("%s\n", def);
+ printf("%s\n", def ?: "");
return 0;
}
/* fall through */
@@ -350,6 +348,23 @@ static int conf_string(struct menu *menu)
}
if (def && sym_set_string_value(sym, def))
return 0;
+
+ /*
+ * A new int or hex symbol whose default fails validation
+ * cannot be set from an empty answer. When standard input is
+ * exhausted, as it is for a non-interactive oldconfig or
+ * syncconfig, re-asking would loop forever and grow the output
+ * until it exhausts memory. Stop with an error that names the
+ * symbol instead. String symbols accept any text, and bool and
+ * tristate symbols (conf_sym()) and choices (conf_choice())
+ * accept the default on an empty line, so they are unaffected.
+ */
+ if (feof(stdin)) {
+ fprintf(stderr,
+ "\nerror: no value for new symbol '%s' at end of input\n",
+ sym->name);
+ exit(1);
+ }
}
}