From 3177e70e2561a6d5f613d7624a4eca6f4dd14779 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sat, 22 Apr 2023 16:36:27 +0100 Subject: [PATCH] [misc] fix CodeQL warnings --- src/badblocks.c | 8 ++++---- src/dos.c | 6 +++--- src/drive.c | 6 +++--- src/format.c | 2 +- src/format_fat32.c | 10 +++++----- src/iso.c | 2 +- src/net.c | 2 +- src/parser.c | 2 +- src/process.c | 2 +- src/rufus.rc | 10 +++++----- src/syslinux.c | 2 +- src/vhd.c | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/badblocks.c b/src/badblocks.c index 76a4f6fc..a20d55f8 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -4,7 +4,7 @@ * Copyright 1992-1994 Remy Card * Copyright 1995-1999 Theodore Ts'o * Copyright 1999 David Beattie - * Copyright 2011-2019 Pete Batard + * Copyright 2011-2023 Pete Batard * * This file is based on the minix file system programs fsck and mkfs * written and copyrighted by Linus Torvalds @@ -377,7 +377,7 @@ static int64_t do_read (HANDLE hDrive, unsigned char * buffer, uint64_t tryout, if (got < 0) got = 0; if (got & 511) - uprintf("%sWeird value (%ld) in do_read\n", bb_prefix, got); + uprintf("%sWeird value (%lld) in do_read\n", bb_prefix, got); got /= block_size; return got; } @@ -399,7 +399,7 @@ static int64_t do_write(HANDLE hDrive, unsigned char * buffer, uint64_t tryout, if (got < 0) got = 0; if (got & 511) - uprintf("%sWeird value (%ld) in do_write\n", bb_prefix, got); + uprintf("%sWeird value (%lld) in do_write\n", bb_prefix, got); got /= block_size; return got; } @@ -447,7 +447,7 @@ static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size if (detect_fakes && (pat_idx == 0)) { srand((unsigned int)GetTickCount64()); id_offset = rand() * (block_size - sizeof(blk64_t)) / RAND_MAX; - uprintf("%sUsing offset %d for fake device check\n", bb_prefix, id_offset); + uprintf("%sUsing offset %zu for fake device check\n", bb_prefix, id_offset); } // coverity[dont_call] pattern_fill(buffer, pattern[pattern_type][pat_idx], blocks_at_once * block_size); diff --git a/src/dos.c b/src/dos.c index 010c8692..6ffb426c 100644 --- a/src/dos.c +++ b/src/dos.c @@ -2,7 +2,7 @@ * Rufus: The Reliable USB Formatting Utility * DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll * (MS WinME DOS) or from the embedded FreeDOS resource files - * Copyright © 2011-2021 Pete Batard + * Copyright © 2011-2023 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -235,7 +235,7 @@ static BOOL ExtractFAT(int entry, const char* path) filestart = (dir_entry->FirstCluster + FAT12_CLUSTER_OFFSET)*FAT12_CLUSTER_SIZE; filesize = dir_entry->FileSize; if ((filestart + filesize) > DiskImageSize) { - uprintf("FAT File %s would be out of bounds: %X, %X", filename, filestart, filesize); + uprintf("FAT File %s would be out of bounds: %zX, %zX", filename, filestart, filesize); uprintf("%X, %X", dir_entry->FirstCluster, dir_entry->FileSize); return FALSE; } @@ -278,7 +278,7 @@ static BOOL ExtractFAT(int entry, const char* path) } safe_closehandle(hFile); - uprintf("Successfully wrote '%s' (%d bytes)", filename, filesize); + uprintf("Successfully wrote '%s' (%zu bytes)", filename, filesize); return TRUE; } diff --git a/src/drive.c b/src/drive.c index 54f5fd4c..cd6e8693 100644 --- a/src/drive.c +++ b/src/drive.c @@ -1129,7 +1129,7 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT* goto out; } if (size > sizeof(drives)) { - uprintf("GetLogicalDriveStrings: Buffer too small (required %d vs. %d)", size, sizeof(drives)); + uprintf("GetLogicalDriveStrings: Buffer too small (required %lu vs. %zu)", size, sizeof(drives)); goto out; } @@ -1266,7 +1266,7 @@ char GetUnusedDriveLetter(void) return 0; } if (size > sizeof(drives)) { - uprintf("GetLogicalDriveStrings: Buffer too small (required %d vs. %d)", size, sizeof(drives)); + uprintf("GetLogicalDriveStrings: Buffer too small (required %lu vs. %zu)", size, sizeof(drives)); return 0; } @@ -1295,7 +1295,7 @@ BOOL IsDriveLetterInUse(const char drive_letter) return TRUE; } if (size > sizeof(drives)) { - uprintf("GetLogicalDriveStrings: Buffer too small (required %d vs. %d)", size, sizeof(drives)); + uprintf("GetLogicalDriveStrings: Buffer too small (required %lu vs. %zu)", size, sizeof(drives)); return TRUE; } diff --git a/src/format.c b/src/format.c index 3ac1a1ca..095383e0 100644 --- a/src/format.c +++ b/src/format.c @@ -736,7 +736,7 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi if (num_sectors_to_clear < 4) num_sectors_to_clear = (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR); - uprintf("Erasing %d sectors", num_sectors_to_clear); + uprintf("Erasing %llu sectors", num_sectors_to_clear); pZeroBuf = calloc(SectorSize, (size_t)num_sectors_to_clear); if (pZeroBuf == NULL) { FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY; diff --git a/src/format_fat32.c b/src/format_fat32.c index 817f745d..451f6605 100644 --- a/src/format_fat32.c +++ b/src/format_fat32.c @@ -394,17 +394,17 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS } // Now we're committed - print some info first - uprintf("Size : %s %u sectors", SizeToHumanReadable(piDrive.PartitionLength.QuadPart, TRUE, FALSE), TotalSectors); - uprintf("Cluster size %d bytes, %d bytes per sector", SectorsPerCluster * BytesPerSect, BytesPerSect); + uprintf("Size : %s %lu sectors", SizeToHumanReadable(piDrive.PartitionLength.QuadPart, TRUE, FALSE), TotalSectors); + uprintf("Cluster size %lu bytes, %lu bytes per sector", SectorsPerCluster * BytesPerSect, BytesPerSect); uprintf("Volume ID is %x:%x", VolumeId >> 16, VolumeId & 0xffff); - uprintf("%d Reserved sectors, %d sectors per FAT, %d FATs", ReservedSectCount, FatSize, NumFATs); - uprintf("%d Total clusters", ClusterCount); + uprintf("%lu Reserved sectors, %lu sectors per FAT, %lu FATs", ReservedSectCount, FatSize, NumFATs); + uprintf("%llu Total clusters", ClusterCount); // Fix up the FSInfo sector pFAT32FsInfo->dFree_Count = (UserAreaSize / SectorsPerCluster) - 1; pFAT32FsInfo->dNxt_Free = 3; // clusters 0-1 reserved, we used cluster 2 for the root dir - uprintf("%d Free clusters", pFAT32FsInfo->dFree_Count); + uprintf("%lu Free clusters", pFAT32FsInfo->dFree_Count); // Work out the Cluster count // First zero out ReservedSect + FatSize * NumFats + SectorsPerCluster diff --git a/src/iso.c b/src/iso.c index 4fc42ace..3ff9b49e 100644 --- a/src/iso.c +++ b/src/iso.c @@ -1465,7 +1465,7 @@ int iso9660_readfat(intptr_t pp, void *buf, size_t secsize, libfat_sector_t sec) iso9660_readfat_private* p_private = (iso9660_readfat_private*)pp; if (sizeof(p_private->buf) % secsize != 0) { - uprintf("iso9660_readfat: Sector size %d is not a divisor of %d", secsize, sizeof(p_private->buf)); + uprintf("iso9660_readfat: Sector size %zu is not a divisor of %zu", secsize, sizeof(p_private->buf)); return 0; } diff --git a/src/net.c b/src/net.c index 1ad8412f..c234b1ca 100644 --- a/src/net.c +++ b/src/net.c @@ -994,7 +994,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, dwPipeSize, dwPipeSize, 0, NULL); if (hPipe == INVALID_HANDLE_VALUE) { - uprintf("Could not create pipe '%s': %s", pipe, WindowsErrorString); + uprintf("Could not create pipe '%s': %s", pipe, WindowsErrorString()); goto out; } diff --git a/src/parser.c b/src/parser.c index d3ebe816..e6a16f01 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1341,7 +1341,7 @@ static BOOL get_data_from_asn1_internal(const uint8_t* buf, size_t buf_len, cons } if (len > buf_len - pos) { - uprintf("get_data_from_asn1: Overflow error (computed length %d is larger than remaining data)", len); + uprintf("get_data_from_asn1: Overflow error (computed length %zu is larger than remaining data)", len); return FALSE; } } diff --git a/src/process.c b/src/process.c index 4891c20f..356a0b01 100644 --- a/src/process.c +++ b/src/process.c @@ -728,7 +728,7 @@ BOOL SearchProcessAlt(char* HandleName) bFound = TRUE; uprintf("WARNING: The following process(es) or service(s) are accessing %s:", HandleName); for (i = 0; i < info->NumberOfProcessIdsInList; i++) { - uprintf("o Process with PID %ld", info->ProcessIdList[i]); + uprintf("o Process with PID %llu", (uint64_t)info->ProcessIdList[i]); } } diff --git a/src/rufus.rc b/src/rufus.rc index fbf3e722..2b6f6eda 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -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.0.2028" +CAPTION "Rufus 4.0.2029" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,0,2028,0 - PRODUCTVERSION 4,0,2028,0 + FILEVERSION 4,0,2029,0 + PRODUCTVERSION 4,0,2029,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.0.2028" + VALUE "FileVersion", "4.0.2029" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.0.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.0.2028" + VALUE "ProductVersion", "4.0.2029" END END BLOCK "VarFileInfo" diff --git a/src/syslinux.c b/src/syslinux.c index 3762fe87..d0847e49 100644 --- a/src/syslinux.c +++ b/src/syslinux.c @@ -72,7 +72,7 @@ int libfat_readfile(intptr_t pp, void *buf, size_t secsize, libfat_sector_t sect } if (bytes_read != secsize) { - uprintf("Sector %llu: Read %d bytes instead of %d requested", sector, bytes_read, secsize); + uprintf("Sector %llu: Read %lu bytes instead of %zu requested", sector, bytes_read, secsize); return 0; } diff --git a/src/vhd.c b/src/vhd.c index 93d85dc2..eb3d481d 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -368,7 +368,7 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV case WIM_MSG_ERROR: if (level == NULL) level = "error"; SetLastError((DWORD)lParam); - uprintf("WIM processing %s: %S [err = %d]\n", level, (PWSTR)wParam, WindowsErrorString()); + uprintf("WIM processing %s: %S [%s]\n", level, (PWSTR)wParam, WindowsErrorString()); break; }