Re: [edk2] [ScsiDiskDxe] Implict type conversion bug

2017-04-10 Thread Zeng, Star
Hao has sent patch for this issue.
You can search emails with title "[edk2] [PATCH] MdeModulePkg/ScsiDiskDxe: Fix 
potential implicit sign extension".

Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Guoheyi
Sent: Monday, April 10, 2017 5:40 PM
To: edk2-devel@lists.01.org
Cc: Tian, Feng <feng.t...@intel.com>
Subject: [edk2] [ScsiDiskDxe] Implict type conversion bug

Hi folks,

In MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c, Line 2757, we have the code as 
below:

ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
  (Capacity10->LastLba2 << 16) |
  (Capacity10->LastLba1 << 8)  |
   Capacity10->LastLba0;

However, we tested on VS2008 and found that the intermediate result would be 
convert to INT32 then INT64 implicitly, so the result will be sign extended and 
LastBlock may not be assigned with what is expected. We can simply test 
LastLba3 >= 0x80 to see what will happen.

Please let me know your comments.

Thanks and regards,

Gary (Heyi Guo)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [ScsiDiskDxe] Implict type conversion bug

2017-04-10 Thread Guoheyi
Hi folks,

In MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c, Line 2757, we have the code as 
below:

ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
  (Capacity10->LastLba2 << 16) |
  (Capacity10->LastLba1 << 8)  |
   Capacity10->LastLba0;

However, we tested on VS2008 and found that the intermediate result would be 
convert to INT32 then INT64 implicitly, so the result will be sign extended and 
LastBlock may not be assigned with what is expected. We can simply test 
LastLba3 >= 0x80 to see what will happen.

Please let me know your comments.

Thanks and regards,

Gary (Heyi Guo)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel