- Use little endian packingl in gpt tests
- Fix integer overflows with DVH disk label
This commit is contained in:
parent
0b7af917e2
commit
47b8266825
152
0092-testing-Use-little-endian-packing-in-gpt-tests.patch
Normal file
152
0092-testing-Use-little-endian-packing-in-gpt-tests.patch
Normal file
@ -0,0 +1,152 @@
|
||||
From 248262f5778ab64a0ccb03d3a269feb245f9b844 Mon Sep 17 00:00:00 2001
|
||||
From: "Brian C. Lane" <bcl@redhat.com>
|
||||
Date: Tue, 8 Apr 2014 17:08:22 -0700
|
||||
Subject: [PATCH 92/93] testing: Use little-endian packing in gpt tests
|
||||
|
||||
Fix gpt-header-move.py and gpt-header-munge to use little endian when
|
||||
packing and unpacking. This allows us to turn the t0210 and t0211 tests
|
||||
back on for big-endian systems.
|
||||
|
||||
* tests/gpt-header-move.py: Use little endian for pack/unpack
|
||||
* tests/gpt-header-munge: Same
|
||||
* tests/t-lib-helpers.sh: Add requires_64bit_ that checks for x86_64 and ppc64
|
||||
* tests/t0210-gpt-resized-partition-entry-array.sh: Remove x86_64 test
|
||||
* tests/t0211-gpt-rewrite-header.sh: Same
|
||||
---
|
||||
tests/gpt-header-move.py | 16 ++++++++--------
|
||||
tests/gpt-header-munge | 6 +++---
|
||||
tests/t-lib-helpers.sh | 12 ++++++++++++
|
||||
tests/t0210-gpt-resized-partition-entry-array.sh | 6 ++----
|
||||
tests/t0211-gpt-rewrite-header.sh | 6 ++----
|
||||
5 files changed, 27 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/tests/gpt-header-move.py b/tests/gpt-header-move.py
|
||||
index 69d1479..977febb 100644
|
||||
--- a/tests/gpt-header-move.py
|
||||
+++ b/tests/gpt-header-move.py
|
||||
@@ -8,14 +8,14 @@ import sys
|
||||
file = open(sys.argv[1],'rb+')
|
||||
file.seek(512)
|
||||
gptheader = file.read(512)
|
||||
-altlba = unpack_from('q', gptheader,offset=32)[0]
|
||||
+altlba = unpack_from('<q', gptheader,offset=32)[0]
|
||||
gptheader = array.array('c',gptheader)
|
||||
-pack_into('Q', gptheader, 32, altlba-33)
|
||||
+pack_into('<Q', gptheader, 32, altlba-33)
|
||||
#zero header crc
|
||||
-pack_into('L', gptheader, 16, 0)
|
||||
+pack_into('<L', gptheader, 16, 0)
|
||||
#compute new crc
|
||||
newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
|
||||
-pack_into('L', gptheader, 16, newcrc)
|
||||
+pack_into('<L', gptheader, 16, newcrc)
|
||||
file.seek(512)
|
||||
file.write(gptheader)
|
||||
file.seek(512*altlba)
|
||||
@@ -25,14 +25,14 @@ backup = file.read(512*32)
|
||||
altlba -= 33
|
||||
gptheader = array.array('c',gptheader)
|
||||
#update mylba
|
||||
-pack_into('Q', gptheader, 24, altlba)
|
||||
+pack_into('<Q', gptheader, 24, altlba)
|
||||
#update table lba
|
||||
-pack_into('Q', gptheader, 72, altlba-32)
|
||||
+pack_into('<Q', gptheader, 72, altlba-32)
|
||||
#zero header crc
|
||||
-pack_into('L', gptheader, 16, 0)
|
||||
+pack_into('<L', gptheader, 16, 0)
|
||||
#compute new crc
|
||||
newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
|
||||
-pack_into('L', gptheader, 16, newcrc)
|
||||
+pack_into('<L', gptheader, 16, newcrc)
|
||||
file.seek(512*(altlba-32))
|
||||
file.write(backup)
|
||||
file.write(gptheader)
|
||||
diff --git a/tests/gpt-header-munge b/tests/gpt-header-munge
|
||||
index e7d3d43..5c0dd80 100755
|
||||
--- a/tests/gpt-header-munge
|
||||
+++ b/tests/gpt-header-munge
|
||||
@@ -107,7 +107,7 @@ sub check_GPT_header ($$$)
|
||||
}
|
||||
|
||||
# Save a copy of the CRC, then zero that field, bytes 16..19:
|
||||
- my $orig_crc = unpack ('L', substr ($buf, 16, 4));
|
||||
+ my $orig_crc = unpack ('L<', substr ($buf, 16, 4));
|
||||
substr ($buf, 16, 4) = "\0" x 4;
|
||||
|
||||
# Compute CRC32 of header: it'd better match.
|
||||
@@ -133,7 +133,7 @@ sub set_CRCs ($$$$)
|
||||
|
||||
# Compute CRC of primary partition array and put it in substr ($pri, 88, 4)
|
||||
my $pa_crc = partition_array_crc $pri_or_backup, $n_pe, $in;
|
||||
- substr ($$buf, 88, 4) = pack ('L', $pa_crc);
|
||||
+ substr ($$buf, 88, 4) = pack ('L<', $pa_crc);
|
||||
|
||||
# In the backup header, we must also set the 8-byte "Partition entries
|
||||
# starting LBA number" field to reflect our new value of $n_pe.
|
||||
@@ -151,7 +151,7 @@ sub set_CRCs ($$$$)
|
||||
# slot into which we'll store the result.
|
||||
substr ($$buf, 16, 4) = "\0" x 4;
|
||||
my $crc = crc32($$buf);
|
||||
- substr ($$buf, 16, 4) = pack ('L', $crc);
|
||||
+ substr ($$buf, 16, 4) = pack ('L<', $crc);
|
||||
}
|
||||
|
||||
sub usage ($)
|
||||
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
|
||||
index 6721003..4e83a05 100644
|
||||
--- a/tests/t-lib-helpers.sh
|
||||
+++ b/tests/t-lib-helpers.sh
|
||||
@@ -398,3 +398,15 @@ device_mapper_required_()
|
||||
. "$abs_top_srcdir/tests/t-lvm.sh"
|
||||
lvm_init_root_dir_ || fail_ "device mapper setup failed"
|
||||
}
|
||||
+
|
||||
+# Require a 64bit system
|
||||
+require_64bit_()
|
||||
+{
|
||||
+ case $(uname -m) in
|
||||
+ x86_64|ppc64)
|
||||
+ return 0;;
|
||||
+ *)
|
||||
+ skip_ "This test requires a 64 bit system"
|
||||
+ ;;
|
||||
+ esac
|
||||
+}
|
||||
diff --git a/tests/t0210-gpt-resized-partition-entry-array.sh b/tests/t0210-gpt-resized-partition-entry-array.sh
|
||||
index 512f342..86fb8ce 100755
|
||||
--- a/tests/t0210-gpt-resized-partition-entry-array.sh
|
||||
+++ b/tests/t0210-gpt-resized-partition-entry-array.sh
|
||||
@@ -19,10 +19,8 @@
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
|
||||
require_perl_digest_crc_
|
||||
|
||||
-# gpt-header-munge will fail on big-endian systems
|
||||
-if test $(uname -m) != x86_64; then
|
||||
- skip_ 'this test only works on little-endian systems'
|
||||
-fi
|
||||
+# gpt-header-munge won't work on 32bit systems
|
||||
+require_64bit_
|
||||
|
||||
ss=$sector_size_
|
||||
|
||||
diff --git a/tests/t0211-gpt-rewrite-header.sh b/tests/t0211-gpt-rewrite-header.sh
|
||||
index a87e753..ee33e43 100644
|
||||
--- a/tests/t0211-gpt-rewrite-header.sh
|
||||
+++ b/tests/t0211-gpt-rewrite-header.sh
|
||||
@@ -23,10 +23,8 @@
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir
|
||||
require_perl_digest_crc_
|
||||
|
||||
-# gpt-header-munge will fail on big-endian systems
|
||||
-if test $(uname -m) != x86_64; then
|
||||
- skip_ 'this test only works on little-endian systems'
|
||||
-fi
|
||||
+# gpt-header-munge won't work on 32bit systems
|
||||
+require_64bit_
|
||||
|
||||
ss=$sector_size_
|
||||
|
||||
--
|
||||
1.9.0
|
||||
|
@ -0,0 +1,50 @@
|
||||
From 1f3ea39d4b6b8576c6ac3797c3c9820fcc7107b8 Mon Sep 17 00:00:00 2001
|
||||
From: Ming Liu <ming.liu@windriver.com>
|
||||
Date: Sat, 16 Feb 2013 10:16:20 +0800
|
||||
Subject: [PATCH 93/93] libparted: fix several integer overflows with dvh
|
||||
labels
|
||||
|
||||
Integer overflows was found in libparted/labels/dvh.c, while attemptting
|
||||
assign unsigned int values to int types in some places.
|
||||
|
||||
Defined by unsigned int instead.
|
||||
|
||||
* libparted/labels/dvh.h: Change int to unsigned int
|
||||
|
||||
Signed-off-by: Ming Liu <ming.liu@windriver.com>
|
||||
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
||||
---
|
||||
libparted/labels/dvh.h | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/libparted/labels/dvh.h b/libparted/labels/dvh.h
|
||||
index 4c25c99..7e7fae7 100644
|
||||
--- a/libparted/labels/dvh.h
|
||||
+++ b/libparted/labels/dvh.h
|
||||
@@ -112,8 +112,8 @@ struct device_parameters {
|
||||
|
||||
struct volume_directory {
|
||||
char vd_name[VDNAMESIZE]; /* name */
|
||||
- int vd_lbn; /* logical block number */
|
||||
- int vd_nbytes; /* file length in bytes */
|
||||
+ unsigned int vd_lbn; /* logical block number */
|
||||
+ unsigned int vd_nbytes; /* file length in bytes */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -125,9 +125,9 @@ struct volume_directory {
|
||||
* NOTE: pt_firstlbn SHOULD BE CYLINDER ALIGNED
|
||||
*/
|
||||
struct partition_table { /* one per logical partition */
|
||||
- int pt_nblks; /* # of logical blks in partition */
|
||||
- int pt_firstlbn; /* first lbn of partition */
|
||||
- int pt_type; /* use of partition */
|
||||
+ unsigned int pt_nblks; /* # of logical blks in partition */
|
||||
+ unsigned int pt_firstlbn; /* first lbn of partition */
|
||||
+ int pt_type; /* use of partition */
|
||||
};
|
||||
|
||||
#define PTYPE_VOLHDR 0 /* partition is volume header */
|
||||
--
|
||||
1.9.0
|
||||
|
10
parted.spec
10
parted.spec
@ -4,7 +4,7 @@
|
||||
Summary: The GNU disk partition manipulation program
|
||||
Name: parted
|
||||
Version: 3.1
|
||||
Release: 18%{?dist}
|
||||
Release: 19%{?dist}
|
||||
License: GPLv3+
|
||||
Group: Applications/System
|
||||
URL: http://www.gnu.org/software/parted
|
||||
@ -114,6 +114,8 @@ Patch0088: 0088-libparted-Fix-check-for-backup-header-location.patch
|
||||
Patch0089: 0089-libparted-Use-common-function-to-calculate-PTE-secto.patch
|
||||
Patch0090: 0090-tests-Add-emit_superuser_warning-for-gpt-tests.patch
|
||||
Patch0091: 0091-tests-Use-msdos-overlap-to-setup-t0283.patch
|
||||
Patch0092: 0092-testing-Use-little-endian-packing-in-gpt-tests.patch
|
||||
Patch0093: 0093-libparted-fix-several-integer-overflows-with-dvh-lab.patch
|
||||
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
@ -130,8 +132,10 @@ BuildRequires: gnupg
|
||||
BuildRequires: git
|
||||
BuildRequires: autoconf automake
|
||||
BuildRequires: e2fsprogs
|
||||
BuildRequires: xfsprogs
|
||||
BuildRequires: dosfstools
|
||||
BuildRequires: perl-Digest-CRC
|
||||
BuildRequires: bc
|
||||
|
||||
Requires(post): /sbin/ldconfig
|
||||
Requires(post): /sbin/install-info
|
||||
@ -251,6 +255,10 @@ fi
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Apr 09 2014 Brian C. Lane <bcl@redhat.com> 3.1-19
|
||||
- Use little endian packing in gpt tests
|
||||
- Fix integer overflows with DVH disk label
|
||||
|
||||
* Tue Apr 08 2014 Brian C. Lane <bcl@redhat.com> 3.1-18
|
||||
- Rebase on new upstream master commit cc382c3
|
||||
- Drop patches incorporated into upstream
|
||||
|
Loading…
Reference in New Issue
Block a user