Skip to content

Commit

Permalink
[librpfile] RpFile_scsi_win32.cpp, rereadDeviceSizeOS(): Check d->fil…
Browse files Browse the repository at this point in the history
…enameW, not d->filename.

d->filename is usually nullptr at this point on Windows.

Also, ensure that d->filenameW is neither NULL nor an empty string.
It shouldn't happen, but a redundant check is better than a crash.

See #413: Exports/Imports table in win32 shell ext page showing blank rows
Reported by @ksharperd.
  • Loading branch information
GerbilSoft committed Jun 2, 2024
1 parent ed2999e commit 10c20cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librpfile/scsi/RpFile_scsi_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ int RpFile::rereadDeviceSizeOS(off64_t *pDeviceSize, uint32_t *pSectorSize)
DWORD dwNumberOfFreeClusters, dwTotalNumberOfClusters;
DWORD w32err = 0;

// FIXME: What if filename is empty?
RP_D(RpFile);
const TCHAR drive_name[4] = {static_cast<TCHAR>(d->filename[0]), _T(':'), _T('\\'), 0};
if (!d->filenameW || d->filenameW[0] == _T('\0')) {
// No filename... Assume this isn't a device.
return -ENODEV;
}
const TCHAR drive_name[4] = {static_cast<TCHAR>(d->filenameW[0]), _T(':'), _T('\\'), 0};
BOOL bRet = GetDiskFreeSpace(drive_name,
&dwSectorsPerCluster, &dwBytesPerSector,
&dwNumberOfFreeClusters, &dwTotalNumberOfClusters);
Expand Down

0 comments on commit 10c20cc

Please sign in to comment.