Permalink
Browse files

. 修正读磁盘越界不报警。

  • Loading branch information...
yaya
yaya committed Dec 23, 2018
1 parent befecee commit d37a26a23372389c2cf9228473a08de949eead5e
Showing with 22 additions and 9 deletions.
  1. +3 −0 ChangeLog_chenall.txt
  2. +2 −0 stage2/asm.S
  3. +7 −5 stage2/bios.c
  4. +3 −2 stage2/builtins.c
  5. +7 −2 stage2/disk_io.c
@@ -1,4 +1,7 @@
更新说明:
2018-12-23(yaya)
修正读磁盘越界不报警。

2018-9-19(yaya)
替换title字符串变量中的换行符。

@@ -8417,6 +8417,8 @@ int13_41:


int13_42_43:
testl $0xffffffff, 12(%si)
jne qtml
movb %ah, %cs:(Save_ah - USB2DRI)
call Disk_package
movb $01, %cl
@@ -591,7 +591,7 @@ get_diskinfo (unsigned long drive, struct geometry *geometry, unsigned long lba1
tmp = (unsigned long long)(geometry->cylinders) *
(unsigned long long)(geometry->heads) *
(unsigned long long)(geometry->sectors);
if (total_sectors < tmp)
// if (total_sectors < tmp)
total_sectors = tmp;
geometry->total_sectors = total_sectors;

@@ -638,12 +638,14 @@ get_diskinfo (unsigned long drive, struct geometry *geometry, unsigned long lba1
printf_warning ("\nWarning: %s sectors per track(%d) is not equal to the BIOS one(%d).\n", err, probed_sectors_per_track, geometry->sectors);

geometry->sectors = probed_sectors_per_track;
if (probed_total_sectors)
geometry->total_sectors = probed_total_sectors;

if (probed_total_sectors > total_sectors)
{
if (drive & 0x80)
printf_warning ("\nWarning: %s total sectors(%d) is greater than the BIOS one(%d).\nSome buggy BIOSes could hang when you access sectors exceeding the BIOS limit.\n", err, probed_total_sectors, total_sectors);
geometry->total_sectors = probed_total_sectors;
// geometry->total_sectors = probed_total_sectors;
}

if (drive & 0x80)
@@ -730,9 +732,9 @@ get_diskinfo (unsigned long drive, struct geometry *geometry, unsigned long lba1

if (geometry->cylinders == 0)
geometry->cylinders = 1;
total_sectors = geometry->cylinders * geometry->heads * geometry->sectors;
if (geometry->total_sectors < total_sectors)
geometry->total_sectors = total_sectors;
// total_sectors = geometry->cylinders * geometry->heads * geometry->sectors;
// if (geometry->total_sectors < total_sectors)
// geometry->total_sectors = total_sectors;

/* backup the geometry into array hd_geom or fd_geom. */

@@ -8442,6 +8442,7 @@ probe_bpb (struct master_and_dos_boot_sector *BS)

if (*(unsigned short *)((char *)BS + 0x16) == 0x6412) //'12 64'
{
probed_total_sectors = *(unsigned long *)((char *)BS + 0x20);
filesystem_type = 7; //fat12-64
return 0;
}
@@ -9175,8 +9176,8 @@ probe_mbr (struct master_and_dos_boot_sector *BS, unsigned long start_sector1, u
probed_heads = best_HPC;
sectors_per_cylinder = probed_heads * probed_sectors_per_track;
probed_cylinders = (Lmax / sectors_per_cylinder) + 1;
if (probed_cylinders < Cmax + 1)
probed_cylinders = Cmax + 1;
// if (probed_cylinders < Cmax + 1)
// probed_cylinders = Cmax + 1;
probed_total_sectors_round = sectors_per_cylinder * probed_cylinders;
probed_total_sectors = Lmax + 1;

@@ -500,8 +500,13 @@ devread (unsigned long long sector, unsigned long long byte_offset, unsigned lon
}

/* Check partition boundaries */
if (((unsigned long long)(sector + ((byte_offset + byte_len - 1) >> sector_size_bits)) >= (unsigned long long)part_length) && part_start)
return !(errnum = ERR_OUTSIDE_PART);
if (((unsigned long long)(sector + ((byte_offset + byte_len - 1) >> sector_size_bits)) >= (unsigned long long)part_length))
{
if (part_start)
return !(errnum = ERR_OUTSIDE_PART);
else
return !(errnum = ERR_READ);
}

/* Get the read to the beginning of a partition. */
sector += byte_offset >> sector_size_bits;

0 comments on commit d37a26a

Please sign in to comment.