summaryrefslogtreecommitdiff
path: root/ubi-utils/new-utils/src/ubiformat.c
diff options
context:
space:
mode:
Diffstat (limited to 'ubi-utils/new-utils/src/ubiformat.c')
-rw-r--r--ubi-utils/new-utils/src/ubiformat.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ubi-utils/new-utils/src/ubiformat.c b/ubi-utils/new-utils/src/ubiformat.c
index 05caed9..fb4f2ee 100644
--- a/ubi-utils/new-utils/src/ubiformat.c
+++ b/ubi-utils/new-utils/src/ubiformat.c
@@ -225,7 +225,10 @@ static int want_exit(void)
while (1) {
normsg_cont("continue? (yes/no) ");
- scanf("%3s", buf);
+ if (scanf("%3s", buf) == EOF) {
+ sys_errmsg("scanf returned unexpected EOF, assume \"yes\"");
+ return 1;
+ }
if (!strncmp(buf, "yes", 3) || !strncmp(buf, "y", 1))
return 0;
if (!strncmp(buf, "no", 2) || !strncmp(buf, "n", 1))
@@ -238,7 +241,10 @@ static int answer_is_yes(void)
char buf[4];
while (1) {
- scanf("%3s", buf);
+ if (scanf("%3s", buf) == EOF) {
+ sys_errmsg("scanf returned unexpected EOF, assume \"no\"");
+ return 0;
+ }
if (!strncmp(buf, "yes", 3) || !strncmp(buf, "y", 1))
return 1;
if (!strncmp(buf, "no", 2) || !strncmp(buf, "n", 1))