diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2007-10-20 22:08:40 +0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2007-10-29 10:59:01 -0400 |
commit | d9039ae0ff3f7929ede576058b3ad3e9c62a47c4 (patch) | |
tree | 82d1a8afb50d9c461011198de0fd40ac016e7f6b /misc/util.c | |
parent | 84d51a2e99277dfb728edc7c5e06273a49d197f5 (diff) | |
download | e2fsprogs-d9039ae0ff3f7929ede576058b3ad3e9c62a47c4.tar.gz |
Check fgets(3) return value
When fgets() function fails, contents of the buffer is undefined. That
is, fgets() return value needs to be checked, to avoid undefined behavior.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/util.c')
-rw-r--r-- | misc/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/misc/util.c b/misc/util.c index 6a4c40cf..7c99a2a2 100644 --- a/misc/util.c +++ b/misc/util.c @@ -71,8 +71,8 @@ void proceed_question(void) fflush(stderr); fputs(_("Proceed anyway? (y,n) "), stdout); buf[0] = 0; - fgets(buf, sizeof(buf), stdin); - if (strchr(short_yes, buf[0]) == 0) + if (!fgets(buf, sizeof(buf), stdin) || + strchr(short_yes, buf[0]) == 0) exit(1); } |