1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] don't pass an output size in DeviceIoControl() when not needed

* Also improve partition creation and address 2 Coverity warnings.
This commit is contained in:
Pete Batard 2024-04-01 14:56:06 +01:00
parent 8a5a5a318a
commit 6dac531552
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
8 changed files with 52 additions and 66 deletions

View file

@ -384,8 +384,7 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save)
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hDrive == INVALID_HANDLE_VALUE)
continue;
if (!DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL))
if (!DeviceIoControl(hDrive, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, geometry, sizeof(geometry), &size, NULL))
continue;
// Rewritable media usually has a one sector
if (DiskGeometry->DiskSize.QuadPart <= 4096)

View file

@ -90,13 +90,12 @@ uint64_t persistence_size = 0;
BOOL SetAutoMount(BOOL enable)
{
HANDLE hMountMgr;
DWORD size;
BOOL ret = FALSE;
hMountMgr = CreateFileA(MOUNTMGR_DOS_DEVICE_NAME, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hMountMgr == INVALID_HANDLE_VALUE)
return FALSE;
ret = DeviceIoControl(hMountMgr, IOCTL_MOUNTMGR_SET_AUTO_MOUNT, &enable, sizeof(enable), NULL, 0, &size, NULL);
ret = DeviceIoControl(hMountMgr, IOCTL_MOUNTMGR_SET_AUTO_MOUNT, &enable, sizeof(enable), NULL, 0, NULL, NULL);
CloseHandle(hMountMgr);
return ret;
}
@ -137,7 +136,6 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
{
int i;
BYTE access_mask = 0;
DWORD size;
uint64_t EndTime;
HANDLE hDrive = INVALID_HANDLE_VALUE;
char DevPath[MAX_PATH];
@ -186,13 +184,13 @@ static HANDLE GetHandle(char* Path, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWr
}
if (bLockDrive) {
if (DeviceIoControl(hDrive, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &size, NULL)) {
if (DeviceIoControl(hDrive, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, NULL, NULL)) {
uprintf("I/O boundary checks disabled");
}
EndTime = GetTickCount64() + DRIVE_ACCESS_TIMEOUT;
do {
if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL))
if (DeviceIoControl(hDrive, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, NULL, NULL))
goto out;
if (IS_ERROR(ErrorStatus)) // User cancel
break;
@ -311,8 +309,7 @@ char* GetLogicalName(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bKeepTrail
continue;
}
r = DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0,
&DiskExtents, sizeof(DiskExtents), &size, NULL);
r = DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &DiskExtents, sizeof(DiskExtents), &size, NULL);
if ((!r) || (size == 0)) {
suprintf("Could not get Disk Extents: %s", r ? "(empty data)" : WindowsErrorString());
safe_closehandle(hDrive);
@ -1063,11 +1060,10 @@ int GetDriveNumber(HANDLE hDrive, char* path)
BOOL s;
int r = -1;
if (!DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0,
&DiskExtents, sizeof(DiskExtents), &size, NULL) || (size <= 0) || (DiskExtents.NumberOfDiskExtents < 1) ) {
if (!DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &DiskExtents, sizeof(DiskExtents), &size, NULL) ||
(size <= 0) || (DiskExtents.NumberOfDiskExtents < 1)) {
// DiskExtents are NO_GO (which is the case for external USB HDDs...)
s = DeviceIoControl(hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &DeviceNumber, sizeof(DeviceNumber),
&size, NULL);
s = DeviceIoControl(hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &DeviceNumber, sizeof(DeviceNumber), &size, NULL);
if ((!s) || (size == 0)) {
uprintf("Could not get device number for device %s %s", path, s ? "(empty data)" : WindowsErrorString());
return -1;
@ -1181,8 +1177,7 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
// handling to determine if they are fixed or removable.
if ((drives_found == 0) && (drive_type != NULL)) {
hPhysical = GetPhysicalHandle(DriveIndex + DRIVE_INDEX_MIN, FALSE, FALSE, FALSE);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, geometry, sizeof(geometry), &size, NULL);
safe_closehandle(hPhysical);
if (r && size > 0) {
if (DiskGeometry->Geometry.MediaType == FixedMedia)
@ -1314,7 +1309,7 @@ BOOL IsDriveLetterInUse(const char drive_letter)
BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label, BOOL bSilent)
{
HANDLE hPhysical;
DWORD size, error;
DWORD error;
static char VolumeLabel[MAX_PATH + 1] = { 0 };
char DrivePath[] = "#:\\", AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
WCHAR VolumeName[MAX_PATH + 1] = { 0 }, FileSystemName[64];
@ -1344,7 +1339,7 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label, BOOL bSilent)
// In the case of card readers with no card, users can get an annoying popup asking them
// to insert media. Use IOCTL_STORAGE_CHECK_VERIFY to prevent this
hPhysical = GetPhysicalHandle(DriveIndex, FALSE, FALSE, TRUE);
if (DeviceIoControl(hPhysical, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, &size, NULL))
if (DeviceIoControl(hPhysical, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, NULL, NULL))
AutorunLabel = get_token_data_file("label", AutorunPath);
else if (GetLastError() == ERROR_NOT_READY)
suprintf("Ignoring 'autorun.inf' label for drive %c: No media", toupper(letters[0]));
@ -1386,8 +1381,7 @@ uint64_t GetDriveSize(DWORD DriveIndex)
if (hPhysical == INVALID_HANDLE_VALUE)
return FALSE;
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, geometry, sizeof(geometry), &size, NULL);
safe_closehandle(hPhysical);
if (!r || size <= 0)
return 0;
@ -1405,8 +1399,7 @@ BOOL IsMediaPresent(DWORD DriveIndex)
BYTE geometry[128];
hPhysical = GetPhysicalHandle(DriveIndex, FALSE, FALSE, TRUE);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL) && (size > 0);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, geometry, sizeof(geometry), &size, NULL) && (size > 0);
safe_closehandle(hPhysical);
return r;
}
@ -1509,8 +1502,7 @@ uint64_t GetEspOffset(DWORD DriveIndex)
if (hPhysical == INVALID_HANDLE_VALUE)
return FALSE;
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
NULL, 0, layout, sizeof(layout), &size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, layout, sizeof(layout), &size, NULL);
if (!r || size <= 0) {
uprintf("Could not get layout for drive 0x%02x: %s", DriveIndex, WindowsErrorString());
goto out;
@ -1694,7 +1686,7 @@ BOOL ToggleEsp(DWORD DriveIndex, uint64_t PartitionOffset)
}
DriveLayout->PartitionEntry[esp_index].RewritePartition = TRUE; // Just in case
r = DeviceIoControl(hPhysical, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)DriveLayout, dl_size, NULL, 0, &dl_size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)DriveLayout, dl_size, NULL, 0, NULL, NULL);
if (!r) {
uprintf("Could not set drive layout: %s", WindowsErrorString());
goto out;
@ -1881,8 +1873,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
if (hPhysical == INVALID_HANDLE_VALUE)
return FALSE;
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, geometry, sizeof(geometry), &size, NULL);
if (!r || size <= 0) {
suprintf("Could not get geometry for drive 0x%02x: %s", DriveIndex, WindowsErrorString());
safe_closehandle(hPhysical);
@ -1904,8 +1895,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
suprintf("Cylinders: %" PRIi64 ", Tracks per cylinder: %d, Sectors per track: %d",
DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
NULL, 0, layout, sizeof(layout), &size, NULL );
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, layout, sizeof(layout), &size, NULL );
if (!r || size <= 0) {
suprintf("Could not get layout for drive 0x%02x: %s", DriveIndex, WindowsErrorString());
safe_closehandle(hPhysical);
@ -2062,9 +2052,7 @@ out:
*/
BOOL UnmountVolume(HANDLE hDrive)
{
DWORD size;
if (!DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &size, NULL)) {
if (!DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, NULL, NULL)) {
uprintf("Could not unmount drive: %s", WindowsErrorString());
return FALSE;
}
@ -2355,7 +2343,6 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
mi = partition_index[PI_MAIN];
wcscpy(SelectedDrive.Partition[mi].Name, write_as_esp ? L"EFI System Partition" : L"Main Data Partition");
if (extra_partitions) {
// Adjust the size according to extra partitions (which we always align to a track)
// TODO: Should we align these to cluster as well?
@ -2377,8 +2364,10 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
wcscpy(SelectedDrive.Partition[pi].Name, L"BIOS Compatibility");
SelectedDrive.Partition[pi++].Size = bytes_per_track; // One track for the extra partition
}
assert(pi <= MAX_PARTITIONS);
}
assert(pi <= MAX_PARTITIONS);
if (pi > MAX_PARTITIONS)
return FALSE;
// Compute the offsets of the extra partitions (which we always align to a track)
last_offset = SelectedDrive.DiskSize;
@ -2536,7 +2525,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// If you don't call IOCTL_DISK_CREATE_DISK, the IOCTL_DISK_SET_DRIVE_LAYOUT_EX call will fail
size = sizeof(CreateDisk);
if (!DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK, (BYTE*)&CreateDisk, size, NULL, 0, &size, NULL)) {
if (!DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK, (BYTE*)&CreateDisk, size, NULL, 0, NULL, NULL)) {
uprintf("Could not reset disk: %s", WindowsErrorString());
return FALSE;
}
@ -2545,8 +2534,10 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
RefreshDriveLayout(hDrive);
size = sizeof(DriveLayoutEx) - ((partition_style == PARTITION_STYLE_GPT) ?
((4 - pi) * sizeof(PARTITION_INFORMATION_EX)) : 0);
if (!DeviceIoControl(hDrive, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)&DriveLayoutEx, size, NULL, 0, &size, NULL)) {
((MAX_PARTITIONS - pi) * sizeof(PARTITION_INFORMATION_EX)) : 0);
// The DRIVE_LAYOUT_INFORMATION_EX used by Microsoft, with its 1-sized array, is designed to overrun...
// coverity[overrun-buffer-arg]
if (!DeviceIoControl(hDrive, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)&DriveLayoutEx, size, NULL, 0, NULL, NULL)) {
uprintf("Could not set drive layout: %s", WindowsErrorString());
return FALSE;
}
@ -2560,10 +2551,9 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
BOOL RefreshDriveLayout(HANDLE hDrive)
{
BOOL r;
DWORD size;
// Diskpart does call the following IOCTL this after updating the partition table, so we do too
r = DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &size, NULL );
r = DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, NULL, NULL);
if (!r)
uprintf("Could not refresh drive layout: %s", WindowsErrorString());
return r;
@ -2573,20 +2563,17 @@ BOOL RefreshDriveLayout(HANDLE hDrive)
BOOL InitializeDisk(HANDLE hDrive)
{
BOOL r;
DWORD size;
CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}};
uprintf("Initializing disk...");
size = sizeof(CreateDisk);
r = DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK,
(BYTE*)&CreateDisk, size, NULL, 0, &size, NULL );
r = DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK, (BYTE*)&CreateDisk, sizeof(CreateDisk), NULL, 0, NULL, NULL);
if (!r) {
uprintf("Could not delete drive layout: %s", WindowsErrorString());
return FALSE;
}
r = DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &size, NULL );
r = DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, NULL, NULL);
if (!r) {
uprintf("Could not refresh drive layout: %s", WindowsErrorString());
return FALSE;
@ -2629,8 +2616,7 @@ BOOL IsMsDevDrive(DWORD DriveIndex)
if (hPhysical == INVALID_HANDLE_VALUE)
goto out;
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
NULL, 0, layout, sizeof(layout), &size, NULL);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, layout, sizeof(layout), &size, NULL);
if (!r || size <= 0)
goto out;

View file

@ -348,8 +348,7 @@ typedef struct _DRIVE_LAYOUT_INFORMATION_EX4 {
} DRIVE_LAYOUT_INFORMATION_EX4, *PDRIVE_LAYOUT_INFORMATION_EX4;
static __inline BOOL UnlockDrive(HANDLE hDrive) {
DWORD size;
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, NULL, NULL);
}
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)

View file

@ -771,8 +771,7 @@ out:
static BOOL WriteMBR(HANDLE hPhysicalDrive)
{
BOOL r = FALSE;
DWORD size;
unsigned char* buffer = NULL;
uint8_t* buffer = NULL;
FAKE_FD fake_fd = { 0 };
FILE* fp = (FILE*)&fake_fd;
const char* using_msg = "Using %s MBR";
@ -791,7 +790,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
// FormatEx rewrites the MBR and removes the LBA attribute of FAT16
// and FAT32 partitions - we need to correct this in the MBR
buffer = (unsigned char*)_mm_malloc(SelectedDrive.SectorSize, 16);
buffer = (uint8_t*)_mm_malloc(SelectedDrive.SectorSize, 16);
if (buffer == NULL) {
uprintf("Could not allocate memory for MBR");
ErrorStatus = RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY);
@ -897,7 +896,7 @@ windows_mbr:
notify:
// Tell the system we've updated the disk properties
if (!DeviceIoControl(hPhysicalDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &size, NULL))
if (!DeviceIoControl(hPhysicalDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, NULL, NULL))
uprintf("Failed to notify system about disk properties update: %s", WindowsErrorString());
out:

View file

@ -101,6 +101,9 @@ BOOL ExtractAppIcon(const char* path, BOOL bSilent)
GRPICONDIR* icondir;
icondir = (GRPICONDIR*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDI_ICON), _RT_GROUP_ICON, "icon", &res_size, FALSE);
assert(icondir != NULL && icondir->idCount <= 64);
if (icondir == NULL || icondir->idCount > 64)
goto out;
hFile = CreateFileU(path, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

View file

@ -737,7 +737,7 @@ extern uint16_t GetSyslinuxVersion(char* buf, size_t buf_size, char** ext);
extern BOOL SetAutorun(const char* path);
extern char* FileDialog(BOOL save, char* path, const ext_t* ext, UINT* selected_ext);
extern BOOL FileIO(enum file_io_type io_type, char* path, char** buffer, DWORD* size);
extern unsigned char* GetResource(HMODULE module, char* name, char* type, const char* desc, DWORD* len, BOOL duplicate);
extern uint8_t* GetResource(HMODULE module, char* name, char* type, const char* desc, DWORD* len, BOOL duplicate);
extern DWORD GetResourceSize(HMODULE module, char* name, char* type, const char* desc);
extern DWORD RunCommandWithProgress(const char* cmdline, const char* dir, BOOL log, int msg);
#define RunCommand(cmd, dir, log) RunCommandWithProgress(cmd, dir, log, 0)

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.5.2121"
CAPTION "Rufus 4.5.2122"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -397,8 +397,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,5,2121,0
PRODUCTVERSION 4,5,2121,0
FILEVERSION 4,5,2122,0
PRODUCTVERSION 4,5,2122,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -416,13 +416,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.5.2121"
VALUE "FileVersion", "4.5.2122"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "<22> 2011-2024 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.5.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.5.2121"
VALUE "ProductVersion", "4.5.2122"
END
END
BLOCK "VarFileInfo"

View file

@ -743,12 +743,12 @@ out:
* size is allocated for the resource. Else the buffer is allocate for
* the resource size.
*/
unsigned char* GetResource(HMODULE module, char* name, char* type, const char* desc, DWORD* len, BOOL duplicate)
uint8_t* GetResource(HMODULE module, char* name, char* type, const char* desc, DWORD* len, BOOL duplicate)
{
HGLOBAL res_handle;
HRSRC res;
DWORD res_len;
unsigned char* p = NULL;
uint8_t* p = NULL;
res = FindResourceA(module, name, type);
if (res == NULL) {
@ -765,7 +765,7 @@ unsigned char* GetResource(HMODULE module, char* name, char* type, const char* d
if (duplicate) {
if (*len == 0)
*len = res_len;
p = (unsigned char*)calloc(*len, 1);
p = calloc(*len, 1);
if (p == NULL) {
uprintf("Could not allocate resource '%s'", desc);
goto out;
@ -774,7 +774,7 @@ unsigned char* GetResource(HMODULE module, char* name, char* type, const char* d
if (res_len > *len)
uprintf("WARNING: Resource '%s' was truncated by %d bytes!", desc, res_len - *len);
} else {
p = (unsigned char*)LockResource(res_handle);
p = LockResource(res_handle);
}
*len = res_len;