Ticket #8990: 0002-Intel-add-on-partition-size-greater-than-2-TB-gsoc2015.patch

File 0002-Intel-add-on-partition-size-greater-than-2-TB-gsoc2015.patch, 1.4 KB (added by kushalsingh007, 9 years ago)

Patch with only the changes corresponding to the validation problem.

  • src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp

    From d976d8c942acb831f9e69432090ec2354954299e Mon Sep 17 00:00:00 2001
    From: kushalsingh007 <kushal.spiderman.singh@gmail.com>
    Date: Mon, 26 Jan 2015 12:44:15 +0530
    Subject: [PATCH]     - Previously intel add-on allowed creation of partition
     with size > 2TB,       now it allows partition size and offset to be less
     than 2TB.     - Fixes #8990
    
    ---
     src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp | 9 +++++++--
     1 file changed, 7 insertions(+), 2 deletions(-)
    
    diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp
    index d9c1450..ae61ff0 100644
    a b PartitionMapAddOn::CreatePartitionHandle(BMutablePartition* partition,  
    9090bool
    9191PartitionMapAddOn::CanInitialize(const BMutablePartition* partition)
    9292{
     93    const off_t kMBRLimit = ((off_t)1 <<32) * 512;
     94        // Limit on size is (max_sector_count)*(sector size)=(2^32)*(512)=2TB.
     95       
    9396    // If it's big enough, but not too big (ie. larger than 2^32 blocks) we can
    94     // initialize it.
     97    // initialize it. Also, the highest offset of a partition should be lesser
     98    // than 2TB.
    9599    return partition->Size() >= 2 * partition->BlockSize()
    96         && partition->Size() / partition->BlockSize() < UINT32_MAX;
     100        && partition->Size() <= kMBRLimit
     101        && partition->Offset() < kMBRLimit;
    97102}
    98103
    99104