parted/parted-3.0-libparted-don-t-allow-values-less-than-1.patch
Brian C. Lane 3cb85c39f2 Update to parted v3.0
This changes the spec to run autoreconf so that patches to .am files
will be picked up without having to resort to hand-patching .in files.
This should make parted more maintainable in the future.

Add patch to Fix snap radius and don't allow values < 1 (#665496)
Add tests for the snap radius fix.
2011-06-28 13:33:03 -07:00

36 lines
1.2 KiB
Diff

From bca7bb94e16acb1e88df97a5ce2c38adb76b072d Mon Sep 17 00:00:00 2001
From: Brian C. Lane <bcl@redhat.com>
Date: Tue, 21 Jun 2011 10:44:16 -0700
Subject: [PATCH 2/4] libparted: don't allow values less than 1 (#665496)
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 c2921e3..232f81b 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