[parted-devel] [PATCH 3/8] libparted: (nilfs2) do not fail with tiny partition

Petr Uzel petr.uzel at suse.cz
Wed Sep 28 08:45:04 UTC 2011


nilfs2_probe used to fail with the partition which is 1 sector long,
since NILFS_SB2_OFFSET(x) returns negative number for x < 8. This
led to crash in ped_geometry_read_alloc().

* libparted/fs/nilfs2/nilfs2.c (nilfs2_probe): Make sure sb2off is
not negative.

Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
 libparted/fs/nilfs2/nilfs2.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libparted/fs/nilfs2/nilfs2.c b/libparted/fs/nilfs2/nilfs2.c
index 511b155..6a97443 100644
--- a/libparted/fs/nilfs2/nilfs2.c
+++ b/libparted/fs/nilfs2/nilfs2.c
@@ -115,6 +115,8 @@ nilfs2_probe (PedGeometry* geom)
 		return NULL;
 
 	sb2off = NILFS_SB2_OFFSET(length);
+	if (sb2off < 0)
+		sb2off = 0;
 
 	if (ped_geometry_read_alloc(geom, &sb_v, 2, 1))
 		sb = sb_v;
-- 
1.7.3.4




More information about the parted-devel mailing list