]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
unix/password: Fix file descriptor leak.
authorVladimir Serbinenko <phcoder@gmail.com>
Mon, 26 Jan 2015 08:53:03 +0000 (09:53 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Mon, 26 Jan 2015 08:53:03 +0000 (09:53 +0100)
Found by: Coverity scan.

grub-core/osdep/unix/password.c

index 470a6ea626f14d39e09ae1107019a91e9af603b8..4b9507bce94d4090e3404364847821cc9d86dffa 100644 (file)
@@ -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;
 }