[gparted] Ensure internal detection requires second magic when needed (#783997)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Ensure internal detection requires second magic when needed (#783997)
- Date: Tue, 20 Jun 2017 16:08:12 +0000 (UTC)
commit 87ccf060ce4d5ed3a175a43346d37db8df68fe28
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Jun 20 13:56:38 2017 +0100
Ensure internal detection requires second magic when needed (#783997)
Internal file system detection is broken for detection of LVM2 PVs
because it reports finding LVM2 PV even when only the first magic is
found. Prepare a partition like this:
# lvm pvcreate /dev/sdb1
# hexdump -C /dev/sdb1 > hexdump-1.txt
Clear the second magic:
# python
f = open("/dev/sdb1","w")
f.seek(0x218)
f.write("\x00"*4)
f.close()
quit()
# hexdump -C /dev/sdb1 > hexdump-2.txt
# diff -u hexdump-[12].txt
00000200 4c 41 42 45 4c 4f 4e 45 01 00 00 00 00 00 00 00 |LABELONE........|
-00000210 58 69 83 e1 20 00 00 00 4c 56 4d 32 20 30 30 31 |Xi.. ...LVM2 001|
+00000210 58 69 83 e1 20 00 00 00 00 00 00 00 20 30 30 31 |Xi.. ....... 001|
^^ ^^ ^^ ^^ ^^^^
00000220 52 4b 31 73 50 77 49 66 6a 72 55 4c 6a 4d 30 58 |RK1sPwIfjrULjM0X|
GParted still detects this as an LVM2 PV even though lvm and blkid do
not.
Correct logic error and only perform memcmp() with the second magic when
the second signature is non-NULL.
Bug 783997 - GParted detecting LVM2 PV regardless whether second magic
matches or not
src/GParted_Core.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index a86631e..733c28a 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1379,7 +1379,7 @@ FILESYSTEM GParted_Core::detect_filesystem_internal( PedDevice * lp_device, PedP
}
if ( memcmp( magic1, signatures[i].sig1, len1 ) == 0 &&
- ( signatures[i].sig2 != NULL ||
+ ( signatures[i].sig2 == NULL ||
memcmp( magic2, signatures[i].sig2, len2 ) == 0 ) )
{
fstype = signatures[i].fstype;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]