From a8c858c45470aa6165acec2b2a3ca156124fdb2e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 8 Dec 2008 01:02:00 -0700 Subject: ubi-utils: various fixes gcc-4.3.x introduces a number of new warnings (and we use -Werror) for things like not checking scanf return values and not using explicit formatting. Finally, it caught that we were overflowing our own buffer in unubi.c, so increate the variable size as we want to declare and clear PATH_MAX + 1, then use only PATH_MAX of the variable. Signed-off-by: Tom Rini Signed-off-by: Artem Bityutskiy --- ubi-utils/new-utils/src/ubiformat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ubi-utils/new-utils/src') 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)) -- cgit v1.2.3