Skip to content

Commit 6ac2dfb

Browse files
committed
[misc] fix temp_dir not being properly initialized
* The static_/safe_ string macros were not properly designed to handle the case where an expression such as strlen() rather than a static value was passed for the count, leading to unexpected results, such as excessive truncation of strings. Fix that. * Also fix a buffer overflow in GetDevices() due to using a wrong string length.
1 parent 00dc047 commit 6ac2dfb

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

res/loc/po/sv-SE.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ msgstr ""
33
"Project-Id-Version: 4.5\n"
44
"Report-Msgid-Bugs-To: [email protected]\n"
55
"POT-Creation-Date: 2024-04-26 00:51+0200\n"
6-
"PO-Revision-Date: 2024-04-26 01:29+0200\n"
7-
"Last-Translator: Sopor <[email protected]>\n"
8-
"Language-Team: \n"
6+
"PO-Revision-Date: 2024-04-26 14:23+0100\n"
7+
"Last-Translator: \n"
8+
"Language-Team: Sopor <[email protected]>\n"
99
"Language: sv_SE\n"
1010
"MIME-Version: 1.0\n"
1111
"Content-Type: text/plain; charset=UTF-8\n"

src/dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ BOOL GetDevices(DWORD devnum)
593593
uprintf("Could not allocate Device ID list");
594594
goto out;
595595
}
596-
for (s=0, i=0; s<ARRAYSIZE(usbstor_name); s++) {
596+
for (s = 0, i = 0; s < ARRAYSIZE(usbstor_name); s++) {
597597
list_start[s] = i;
598598
if (list_size[s] > 1) {
599599
if (CM_Get_Device_ID_ListA(usbstor_name[s], &devid_list[i], list_size[s], ulFlags) != CR_SUCCESS)
@@ -985,8 +985,8 @@ BOOL GetDevices(DWORD devnum)
985985
safe_free(devint_detail_data);
986986
break;
987987
}
988-
safe_sprintf(&display_msg[strlen(display_msg)], sizeof(display_msg) - strlen(display_msg),
989-
"%s [%s]", (right_to_left_mode)?RIGHT_TO_LEFT_MARK:"",
988+
safe_sprintf(&display_msg[strlen(display_msg)], sizeof(display_msg) - strlen(display_msg) - 1,
989+
"%s [%s]", (right_to_left_mode) ? RIGHT_TO_LEFT_MARK : "",
990990
SizeToHumanReadable(drive_size, FALSE, use_fake_units));
991991
display_name = display_msg;
992992
}

src/rufus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
151151
#define safe_mm_free(p) do {_mm_free((void*)p); p = NULL;} while(0)
152152
#define safe_min(a, b) min((size_t)(a), (size_t)(b))
153-
#define safe_strcp(dst, dst_max, src, count) do {memmove(dst, src, safe_min(count, dst_max)); \
154-
((char*)(dst))[safe_min(count, dst_max)-1] = 0;} while(0)
153+
#define safe_strcp(dst, dst_max, src, count) do { size_t _count = (count); memmove(dst, src, safe_min(_count, dst_max)); \
154+
((char*)(dst))[safe_min(_count, dst_max)-1] = 0; } while(0)
155155
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
156156
#define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src)
157157
#define safe_strcat(dst, dst_max, src) strncat_s(dst, dst_max, src, _TRUNCATE)
@@ -163,7 +163,7 @@
163163
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
164164
#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
165165
#define safe_release_dc(hDlg, hDC) do {if ((hDC != INVALID_HANDLE_VALUE) && (hDC != NULL)) {ReleaseDC(hDlg, hDC); hDC = NULL;}} while(0)
166-
#define safe_sprintf(dst, count, ...) do {_snprintf_s(dst, count, _TRUNCATE, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
166+
#define safe_sprintf(dst, count, ...) do { size_t _count = (count); _snprintf_s(dst, _count, _TRUNCATE, __VA_ARGS__); (dst)[(_count)-1] = 0; } while(0)
167167
#define static_sprintf(dst, ...) safe_sprintf(dst, sizeof(dst), __VA_ARGS__)
168168
#define safe_atoi(str) ((((char*)(str))==NULL)?0:atoi(str))
169169
#define safe_strlen(str) ((((char*)(str))==NULL)?0:strlen(str))

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.5.2143"
36+
CAPTION "Rufus 4.5.2144"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -397,8 +397,8 @@ END
397397
//
398398

399399
VS_VERSION_INFO VERSIONINFO
400-
FILEVERSION 4,5,2143,0
401-
PRODUCTVERSION 4,5,2143,0
400+
FILEVERSION 4,5,2144,0
401+
PRODUCTVERSION 4,5,2144,0
402402
FILEFLAGSMASK 0x3fL
403403
#ifdef _DEBUG
404404
FILEFLAGS 0x1L
@@ -416,13 +416,13 @@ BEGIN
416416
VALUE "Comments", "https://rufus.ie"
417417
VALUE "CompanyName", "Akeo Consulting"
418418
VALUE "FileDescription", "Rufus"
419-
VALUE "FileVersion", "4.5.2143"
419+
VALUE "FileVersion", "4.5.2144"
420420
VALUE "InternalName", "Rufus"
421421
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
422422
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
423423
VALUE "OriginalFilename", "rufus-4.5.exe"
424424
VALUE "ProductName", "Rufus"
425-
VALUE "ProductVersion", "4.5.2143"
425+
VALUE "ProductVersion", "4.5.2144"
426426
END
427427
END
428428
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)