Skip to content

Commit

Permalink
[misc] fix and silence some Coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Feb 13, 2025
1 parent ec604f4 commit f3c29bf
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion res/loc/po/!update.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
if not exist pollock.exe curl https://files.akeo.ie/pollock/pollock-1.5.exe --output pollock.exe
if not exist pollock.exe curl https://files.akeo.ie/pollock/pollock-1.6.exe --output pollock.exe
cls
:menu
echo 1 - Import .po into .loc
Expand Down
6 changes: 3 additions & 3 deletions res/loc/po/fa-IR.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: 4.5\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-29 19:24+0300\n"
"PO-Revision-Date: 2024-04-29 20:25+0330\n"
"PO-Revision-Date: 2025-02-13 12:00+0000\n"
"Last-Translator: MasterVito <[email protected]>\n"
"Language-Team: \n"
"Language: fa_IR\n"
Expand All @@ -13,7 +13,7 @@ msgstr ""
"X-Poedit-SourceCharset: UTF-8\n"
"X-Rufus-LanguageName: Persian (پارسی)\n"
"X-Rufus-LCID: 0x0429\n"
"X-Generator: Poedit 3.4.2\n"
"X-Generator: Poedit 3.5\n"

#. • IDD_DIALOG → IDS_DRIVE_PROPERTIES_TXT
msgid "Drive Properties"
Expand Down Expand Up @@ -1094,7 +1094,7 @@ msgstr "نسخه %d.%d (Build %d)"

#. • MSG_176
msgid "English translation: Pete Batard <mailto:[email protected]>"
msgstr "ترجمه فارسی:\\line‏ •سید عرفان <mailto:[email protected]>\\line‏ •ضیاءالدین عظیمی <mailto:[email protected]>"
msgstr "ترجمه فارسی:\\line‏ •مستر ویتو <mailto:[email protected]>\\line‏ •ضیاءالدین عظیمی <mailto:[email protected]>"

#. • MSG_177
msgid "Report bugs or request enhancements at:"
Expand Down
2 changes: 1 addition & 1 deletion res/loc/rufus.loc
Original file line number Diff line number Diff line change
Expand Up @@ -10049,7 +10049,7 @@ t MSG_172 "امضای فایل دانلود شده معتبر نیست"
t MSG_173 "برای انتخاب کلیک کنید..."
t MSG_174 "Rufus، ابزاری کاربردی و قابل‌اطمینان برای فرمت کردن درایوهای USB"
t MSG_175 "نسخه %d.%d (Build %d)"
t MSG_176 "ترجمه فارسی:\\line‏ •سید عرفان <mailto:[email protected]>\\line‏ •ضیاءالدین عظیمی <mailto:[email protected]>"
t MSG_176 "ترجمه فارسی:\\line‏ •مستر ویتو <mailto:[email protected]>\\line‏ •ضیاءالدین عظیمی <mailto:[email protected]>"
t MSG_177 "گزارش اشکال (Bug) یا درخواست قابلیت جدید و بهبود نرم‌افزار در:"
t MSG_178 "حقوق نشر دیگران:"
t MSG_179 "سیاست به‌روزرسانی:"
Expand Down
1 change: 1 addition & 0 deletions src/bled/huf_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
if (tableLog <= HUF_DECODER_FAST_TABLELOG && maxTableLog > HUF_DECODER_FAST_TABLELOG) maxTableLog = HUF_DECODER_FAST_TABLELOG;

/* find maxWeight */
// coverity[underflow]
for (maxW = tableLog; wksp->rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */

/* Get start index of each weight */
Expand Down
1 change: 1 addition & 0 deletions src/bled/xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -3402,6 +3402,7 @@ XXH64_finalize(xxh_u64 hash, const xxh_u8* ptr, size_t len, XXH_alignment align)
hash ^= (xxh_u64)(XXH_get32bits(ptr)) * XXH_PRIME64_1;
ptr += 4;
hash = XXH_rotl64(hash, 23) * XXH_PRIME64_2 + XXH_PRIME64_3;
// coverity[overflow_const]
len -= 4;
}
while (len > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/bled/xz_dec_lzma2.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ static void XZ_FUNC lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l,
}
}

// coverity[overflow_const]
s->lzma.len += rc_bittree(&s->rc, probs, limit) - limit;
}

Expand Down
1 change: 1 addition & 0 deletions src/bled/zstd_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he
static ZSTD_frameSizeInfo ZSTD_errorFrameSizeInfo(size_t ret)
{
ZSTD_frameSizeInfo frameSizeInfo;
frameSizeInfo.nbBlocks = 0;
frameSizeInfo.compressedSize = ret;
frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR;
return frameSizeInfo;
Expand Down
14 changes: 12 additions & 2 deletions src/msapi_utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* See also: https://utf8everywhere.org
*
* Copyright © 2010-2023 Pete Batard <[email protected]>
* Copyright © 2010-2025 Pete Batard <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -174,14 +174,24 @@ static __inline DWORD FormatMessageU(DWORD dwFlags, LPCVOID lpSource, DWORD dwMe
DWORD dwLanguageId, char* lpBuffer, DWORD nSize, va_list *Arguments)
{
DWORD ret = 0, err = ERROR_INVALID_DATA;
// coverity[returned_null]
// Exclude support for the FORMAT_MESSAGE_ALLOCATE_BUFFER special case.
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
walloc(lpBuffer, nSize);
if (wlpBuffer == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
ret = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, wlpBuffer, nSize, Arguments);
err = GetLastError();
if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpBuffer, lpBuffer, nSize)) == 0)) {
err = GetLastError();
ret = 0;
}
// Coverity doesn't realise that we filtered out the FORMAT_MESSAGE_ALLOCATE_BUFFER case
// coverity[leaked_storage]
wfree(lpBuffer);
SetLastError(err);
return ret;
Expand Down
7 changes: 4 additions & 3 deletions src/parser.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Elementary Unicode compliant find/replace parser
* Copyright © 2012-2024 Pete Batard <[email protected]>
* Copyright © 2012-2025 Pete Batard <[email protected]>
*
* 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
Expand Down Expand Up @@ -55,7 +55,7 @@ static loc_cmd* get_loc_cmd(char c, char* line) {
char *endptr, *expected_endptr, *token;
loc_cmd* lcmd = NULL;

for (j=0; j<ARRAYSIZE(parse_cmd); j++) {
for (j = 0; j<ARRAYSIZE(parse_cmd); j++) {
if (c == parse_cmd[j].c)
break;
}
Expand Down Expand Up @@ -133,10 +133,11 @@ static loc_cmd* get_loc_cmd(char c, char* line) {
case 'u': // comma or dot separated list of unsigned integers (to end of line)
// count the number of commas
lcmd->unum_size = 1;
for (l=i; line[l] != 0; l++) {
for (l = i; line[l] != 0; l++) {
if ((line[l] == '.') || (line[l] == ','))
lcmd->unum_size++;
}
free(lcmd->unum);
lcmd->unum = (uint32_t*)malloc(lcmd->unum_size * sizeof(uint32_t));
if (lcmd->unum == NULL) {
luprint("could not allocate memory");
Expand Down
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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.7.2219"
CAPTION "Rufus 4.7.2220"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -399,8 +399,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,7,2219,0
PRODUCTVERSION 4,7,2219,0
FILEVERSION 4,7,2220,0
PRODUCTVERSION 4,7,2220,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -418,13 +418,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.7.2219"
VALUE "FileVersion", "4.7.2220"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "� 2011-2025 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.7.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.7.2219"
VALUE "ProductVersion", "4.7.2220"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit f3c29bf

Please sign in to comment.