Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Device-mapper Development (http://www.linux-archive.org/device-mapper-development/)
-   -   kpartx: verify GUID partition entry size (http://www.linux-archive.org/device-mapper-development/631321-kpartx-verify-guid-partition-entry-size.html)

Benjamin Marzinski 02-10-2012 05:14 PM

kpartx: verify GUID partition entry size
 
This patch pulls in some kernel code to catch a corrupt GUID partition
table with the wrong size.

Signed-off-by: Boris Ranto <branto@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
kpartx/gpt.c | 9 +++++++++
1 file changed, 9 insertions(+)

Index: multipath-tools-120123/kpartx/gpt.c
================================================== =================
--- multipath-tools-120123.orig/kpartx/gpt.c
+++ multipath-tools-120123/kpartx/gpt.c
@@ -367,6 +367,15 @@ is_gpt_valid(int fd, uint64_t lba,
}


+ /* Check that sizeof_partition_entry has the correct value */
+ if (__le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
+ // printf("GUID partition entry size check failed.
");
+ free(*gpt);
+ *gpt = NULL;
+ return 0;
+ }
+
+
if (!(*ptes = alloc_read_gpt_entries(fd, *gpt))) {
free(*gpt);
*gpt = NULL;

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


All times are GMT. The time now is 08:05 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.