From 83c256ba421705105eecedd06f97a64b3da79277 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 29 Nov 2013 03:32:57 +0100 Subject: [PATCH] * grub-core/osdep/unix/password.c (grub_password_get): Check that fgets succeeded. --- ChangeLog | 5 +++++ grub-core/osdep/unix/password.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 190a52591..b883d70be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-29 Vladimir Serbinenko + + * grub-core/osdep/unix/password.c (grub_password_get): Check that + fgets succeeded. + 2013-11-27 Francesco Lavra * docs/grub.texi (ls): Fix command description in case of a device name diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 2e647c766..470a6ea62 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -51,7 +51,9 @@ grub_password_get (char buf[], unsigned buf_size) } else tty_changed = 0; - fgets (buf, buf_size, stdin); + grub_memset (buf, 0, buf_size); + if (!fgets (buf, buf_size, stdin)) + return 0; ptr = buf + strlen (buf) - 1; while (buf <= ptr && (*ptr == '\n' || *ptr == '\r')) *ptr-- = 0;