File MARM-fix-insufficient-validation-check-of-M-option.diff of Package efibootmgr

From eed70d9b5e0c278cc7da4f14cd4fbcdf35e47998 Mon Sep 17 00:00:00 2001
From: Taku Izumi <izumi.taku@jp.fujitsu.com>
Date: Tue, 26 Jan 2016 14:32:50 +0900
Subject: [PATCH] Fix insusufficient validation check of -M option

The acceptable range of -M (--mirror-above-4G) option should
be from 0 to 50. So the negative value should be rejected.
Otherwise unintended value can be specified.

e.g.

 > efibootmgr -M -3
...
MirroredPercentageAbove4G: 25.00
MirrorMemoryBelow4GB: true
RequestMirroredPercentageAbove4G: 652.36
RequestMirrorMemoryBelow4GB: true

 652.36 is invalid value for MirroredPercentageAbove4G and should
 not be specified.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 src/efibootmgr/efibootmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 7a5d18e..132a7a4 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -1189,7 +1189,7 @@ parse_opts(int argc, char **argv)
 		case 'M':
 			opts.set_mirror_hi = 1;
 			rc = sscanf(optarg, "%f", &fnum);
-			if (rc == 1 && fnum <= 50) {
+			if (rc == 1 && fnum <= 50 && fnum >= 0) {
 				opts.above4g = fnum * 100; /* percent to basis points */
 			}
 			else {
openSUSE Build Service is sponsored by