[Gptfdisk-general] Bug fix patch for diskio-windows.cc
Brought to you by:
srs5694
From: Edward E. <dev...@gm...> - 2019-02-20 22:29:39
|
On Windows, using UINT32_MAX (which is of course 1<<32 - 1) as a scaling factor to get a uint64_t is causing the sector total to be counted wrong, affecting disks/images >= 4GiB. Among other things, gdisk wants to "fix" the secondary GPT by moving it back one sector (plus one sector for each additional 2TiB). This patch (on current master) uses GetFileSizeEx(), which returns file size as an int64_t. This API was available possibly as far back as Windows 98, so switching to it shouldn't be a problem. Re-compiled on Windows and tested with a known good disk. I believe this bug caused Chris Murphy's issue in https://sourceforge.net/p/gptfdisk/discussion/939590/thread/cc21c83b/ ; it may be involved in https://sourceforge.net/p/gptfdisk/discussion/939590/thread/6b992837/ as well. It may be worthwhile to check if UINT{32,64}_MAX are being used correctly in all other cases. They look OK to me, but I'm not familiar enough with the GPT format to be confident of that assessment. |