grub2/0001-unix-password-Fix-file-descriptor-leak.patch

35 lines
1.0 KiB
Diff
Raw Normal View History

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] unix/password: Fix file descriptor leak.
Found by: Coverity scan.
---
grub-core/osdep/unix/password.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
Index: grub-2.02~beta2/grub-core/osdep/unix/password.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/unix/password.c 2013-12-25 00:29:26.000000000 +0800
+++ grub-2.02~beta2/grub-core/osdep/unix/password.c 2015-09-22 17:10:01.109530851 +0800
@@ -53,7 +53,10 @@
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_xputs ("\n");
grub_refresh ();
+ fclose (in);
+
return 1;
}