summaryrefslogtreecommitdiffstats
path: root/libblkid
diff options
context:
space:
mode:
authorKarel Zak2012-11-21 15:47:56 +0100
committerKarel Zak2012-11-21 15:47:56 +0100
commitf907d66b6346f80ff4d6289eedd46741efa6f415 (patch)
tree84e9e9deb89db604816948c9ce18ba6cbc402e7e /libblkid
parentwipefs: Add --force option to force it to erase. (diff)
downloadkernel-qcow2-util-linux-f907d66b6346f80ff4d6289eedd46741efa6f415.tar.gz
kernel-qcow2-util-linux-f907d66b6346f80ff4d6289eedd46741efa6f415.tar.xz
kernel-qcow2-util-linux-f907d66b6346f80ff4d6289eedd46741efa6f415.zip
libblkid: (gpt) don't modify in memory buffers
LIBBLKID_DEBUG=0xffff blkid -p .... gpt: ---> call probefunc() reuse buffer: off=0 len=1024 pr=0xb0b690 reuse buffer: off=0 len=1024 pr=0xb0b690 reuse buffer: off=1024 len=16384 pr=0xb0b690 GPT entries corrupted reuse buffer: off=10737417728 len=512 pr=0xb0b690 reuse buffer: off=10737401344 len=16384 pr=0xb0b690 GPT entries corrupted gpt: <--- (rc = 1) Reported-by: Dave Reisner <d@falconindy.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid')
-rw-r--r--libblkid/src/partitions/gpt.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c
index ccade6b54..98e82bfd2 100644
--- a/libblkid/src/partitions/gpt.c
+++ b/libblkid/src/partitions/gpt.c
@@ -226,15 +226,15 @@ static struct gpt_header *get_gpt_header(
return NULL;
/* Header has to be verified when header_crc32 is zero */
- orgcrc = le32_to_cpu(h->header_crc32);
+ orgcrc = h->header_crc32;
h->header_crc32 = 0;
-
crc = count_crc32((unsigned char *) h, hsz);
- if (crc != orgcrc) {
+ h->header_crc32 = orgcrc;
+
+ if (crc != le32_to_cpu(orgcrc)) {
DBG(DEBUG_LOWPROBE, printf("GPT header corrupted\n"));
return NULL;
}
- h->header_crc32 = cpu_to_le32(orgcrc);
/* Valid header has to be at MyLBA */
if (le64_to_cpu(h->my_lba) != lba) {
@@ -300,7 +300,7 @@ static int probe_gpt_pt(blkid_probe pr,
blkid_partlist ls;
uint64_t fu, lu;
uint32_t ssf, i;
-
+ efi_guid_t guid;
if (last_lba(pr, &lastlba))
goto nothing;
@@ -369,14 +369,13 @@ static int probe_gpt_pt(blkid_probe pr,
(unsigned char *) e->partition_name,
sizeof(e->partition_name), BLKID_ENC_UTF16LE);
- swap_efi_guid(&e->unique_partition_guid);
- swap_efi_guid(&e->partition_type_guid);
-
- blkid_partition_set_uuid(par,
- (const unsigned char *) &e->unique_partition_guid);
+ guid = e->unique_partition_guid;
+ swap_efi_guid(&guid);
+ blkid_partition_set_uuid(par, (const unsigned char *) &guid);
- blkid_partition_set_type_uuid(par,
- (const unsigned char *) &e->partition_type_guid);
+ guid = e->partition_type_guid;
+ swap_efi_guid(&guid);
+ blkid_partition_set_type_uuid(par, (const unsigned char *) &guid);
blkid_partition_set_flags(par, e->attributes);
}