6f1e3d5
From 1f03d841b2872f5118fc7cbde39f0f19021d16ae Mon Sep 17 00:00:00 2001
bf8e18b
From: Hector Marco-Gisbert <hecmargi@upv.es>
bf8e18b
Date: Fri, 13 Nov 2015 16:21:09 +0100
6f1e3d5
Subject: [PATCH 137/198] Fix security issue when reading username and password
bf8e18b
bf8e18b
  This patch fixes two integer underflows at:
bf8e18b
    * grub-core/lib/crypto.c
bf8e18b
    * grub-core/normal/auth.c
bf8e18b
bf8e18b
Resolves: CVE-2015-8370
bf8e18b
bf8e18b
Signed-off-by: Hector Marco-Gisbert <hecmargi@upv.es>
bf8e18b
Signed-off-by: Ismael Ripoll-Ripoll <iripoll@disca.upv.es>
bf8e18b
---
bf8e18b
 grub-core/lib/crypto.c  | 2 +-
bf8e18b
 grub-core/normal/auth.c | 2 +-
bf8e18b
 2 files changed, 2 insertions(+), 2 deletions(-)
bf8e18b
bf8e18b
diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
bbc6a89
index ca334d5a4..e6c78d16d 100644
bf8e18b
--- a/grub-core/lib/crypto.c
bf8e18b
+++ b/grub-core/lib/crypto.c
bf8e18b
@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)
bf8e18b
 	  break;
bf8e18b
 	}
bf8e18b
 
bf8e18b
-      if (key == '\b')
bf8e18b
+      if (key == '\b' && cur_len)
bf8e18b
 	{
b9efc54
 	  if (cur_len)
b9efc54
 	    cur_len--;
bf8e18b
diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c
bbc6a89
index 6be678c0d..c35ce9724 100644
bf8e18b
--- a/grub-core/normal/auth.c
bf8e18b
+++ b/grub-core/normal/auth.c
bf8e18b
@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)
bf8e18b
 	  break;
bf8e18b
 	}
bf8e18b
 
bbc6a89
-      if (key == GRUB_TERM_BACKSPACE)
bbc6a89
+      if (key == GRUB_TERM_BACKSPACE && cur_len)
bf8e18b
 	{
b9efc54
 	  if (cur_len)
b9efc54
 	    {
bf8e18b
-- 
da63b36
2.14.3
bf8e18b