aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt/hdt-cli-disk.c
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-21 12:05:46 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-21 12:05:46 -0700
commit5fa9fcefee51b0ea0dd27ab655a4acec6426a935 (patch)
tree18452304bdb4a58351ff86da792fb944241f2605 /com32/hdt/hdt-cli-disk.c
parentbb646b9842e85f1bbf51bb1bac1c72e3e763aa03 (diff)
downloadhdt-5fa9fcefee51b0ea0dd27ab655a4acec6426a935.tar.gz
hdt-5fa9fcefee51b0ea0dd27ab655a4acec6426a935.tar.xz
hdt-5fa9fcefee51b0ea0dd27ab655a4acec6426a935.zip
hdt: Do not print information about buggy extended partitions
Impact: bug fix Add a sanity check before printing extended partitions. As hpa notes in chain.c: Sanity check entry: must not extend outside the extended partition. This is necessary since some OSes put crap in some entries. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32/hdt/hdt-cli-disk.c')
-rw-r--r--com32/hdt/hdt-cli-disk.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index 8689a37a..9bd4b1fe 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -109,6 +109,7 @@ static void process_ebr(struct driveinfo *drive_info, struct part_entry *ptab_ro
{
int error;
char *error_buffer;
+ int offset;
/* The ebr is located at the first sector of the extended partition */
char* ebr = read_sectors(drive_info, ptab_root->start_lba, 1, &error);
@@ -121,7 +122,17 @@ static void process_ebr(struct driveinfo *drive_info, struct part_entry *ptab_ro
}
struct part_entry *ptab_child = (struct part_entry *)(ebr + PARTITION_TABLES_OFFSET);
- return process_br(drive_info, ptab_child, ebr_seen, ptab_root);
+
+ if (!ptab_child->length)
+ return;
+
+ offset = ptab_child->start_lba + ptab_root->start_lba;
+
+ if ( offset + ptab_child->length <= ptab_root->start_lba ||
+ offset >= ptab_root->start_lba + ptab_root->length )
+ return;
+ else
+ return process_br(drive_info, ptab_child, ebr_seen, ptab_root);
}
/**