grub2/0235-unix-password-Fix-file-descriptor-leak.patch
Peter Jones 8c6b1ac71e Reconcile with upstream once again.
Also include some minor fixes for gcc 5.1.1

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-07-22 09:46:32 -04:00

38 lines
1023 B
Diff

From 810254093959708aa6a260c59ad3cf3a1d250755 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Mon, 26 Jan 2015 09:53:03 +0100
Subject: [PATCH 235/506] unix/password: Fix file descriptor leak.
Found by: Coverity scan.
---
grub-core/osdep/unix/password.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c
index 470a6ea..4b9507b 100644
--- a/grub-core/osdep/unix/password.c
+++ b/grub-core/osdep/unix/password.c
@@ -53,7 +53,10 @@ grub_password_get (char buf[], unsigned buf_size)
tty_changed = 0;
grub_memset (buf, 0, buf_size);
if (!fgets (buf, buf_size, stdin))
- return 0;
+ {
+ fclose (in);
+ return 0;
+ }
ptr = buf + strlen (buf) - 1;
while (buf <= ptr && (*ptr == '\n' || *ptr == '\r'))
*ptr-- = 0;
@@ -64,5 +67,7 @@ grub_password_get (char buf[], unsigned buf_size)
grub_xputs ("\n");
grub_refresh ();
+ fclose (in);
+
return 1;
}
--
2.4.3