parted/parted-3.0-libparted-fix-a-bug-in-the-nilfs2-probe-function.patch
Brian C. Lane 8e3b457f0f Fix handling of zero-length gpt partitions (#728949)
Fix bug in nilfs2 probe with short partitions (#728949)
Fix bug in hfs probe code (#714758)
Make pc98 detection depend on specific signatures (#646053)
2011-10-07 16:28:22 -07:00

56 lines
1.8 KiB
Diff

From 81a1eb6a888f85074536ed89c5c316de4e918c2b Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sat, 25 Jun 2011 08:49:58 +0200
Subject: [PATCH 2/4] libparted: fix a bug in the nilfs2 probe function
* libparted/fs/nilfs2/nilfs2.c (nilfs2_probe): Reject this partition
if we get a negative sb2 offset. Passing a negative offset to
ped_geometry_read_alloc would evoke a failed assertion.
Bug introduced by 2010-07-09 commit d463e7de.
* NEWS: (Bug fixes): Mention it.
Reported by Daniel Fandrich in
http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10466/focus=10472
---
NEWS | 3 +++
libparted/fs/nilfs2/nilfs2.c | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 24e28e6..d35c6cc 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Bug fixes
+ libparted: no longer aborts (failed assertion) due to a nilfs2_probe bug
+ [bug introduced in parted-2.4 with the addition of nilfs2 support]
+
libparted: no longer aborts when reading a truncated GPT-formatted device
Fix numerous small leaks in both the library and the UI.
diff --git a/libparted/fs/nilfs2/nilfs2.c b/libparted/fs/nilfs2/nilfs2.c
index 511b155..166c54c 100644
--- a/libparted/fs/nilfs2/nilfs2.c
+++ b/libparted/fs/nilfs2/nilfs2.c
@@ -108,13 +108,14 @@ nilfs2_probe (PedGeometry* geom)
struct nilfs2_super_block *sb = NULL;
struct nilfs2_super_block *sb2 = NULL;
PedSector length = geom->length;
- PedSector sb2off;
/* ignore if sector size is not 512bytes for now */
if (geom->dev->sector_size != PED_SECTOR_SIZE_DEFAULT)
return NULL;
- sb2off = NILFS_SB2_OFFSET(length);
+ PedSector sb2off = NILFS_SB2_OFFSET(length);
+ if (sb2off <= 2)
+ return NULL;
if (ped_geometry_read_alloc(geom, &sb_v, 2, 1))
sb = sb_v;
--
1.7.6.4