[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] Don't allow values less than 1 (#665496)
From: |
Brian C. Lane |
Subject: |
[PATCH 2/4] Don't allow values less than 1 (#665496) |
Date: |
Tue, 21 Jun 2011 10:44:16 -0700 |
When a value < 1 is used there is the possibility that the range can
overlap sector 0. The user should use smaller units instead. 0 is a
special case and is still allowed.
* libparted/unit.c (ped_unit_parse_custom): Throw error if a value
between 0 and 1 is used.
---
libparted/unit.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libparted/unit.c b/libparted/unit.c
index 1dafc90..ee0ab05 100644
--- a/libparted/unit.c
+++ b/libparted/unit.c
@@ -531,6 +531,12 @@ ped_unit_parse_custom (const char* str, const PedDevice*
dev, PedUnit unit,
_("Invalid number."));
goto error_free_copy;
}
+ if (num > 0 && num < 1) {
+ ped_exception_throw (
+ PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("Use a smaller unit instead of a value < 1"));
+ goto error_free_copy;
+ }
unit_size = ped_unit_get_size (dev, unit);
radius = (ped_div_round_up (unit_size, dev->sector_size) / 2) - 1;
--
1.7.4.4