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


_______________________________________________
bug-parted mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to