Skip to content

Commit

Permalink
[vhd] fix VHDX being inadvertently saved as VHD
Browse files Browse the repository at this point in the history
* Addresses the error reported in #2468.
* Also use memmove instead of memcpy where overlapping data is involved.
  • Loading branch information
pbatard committed May 12, 2024
1 parent fb43dc8 commit 45423be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ int sanitize_label(char* label)
// Remove all leading '-'
for (i = 0; i < len && label[i] == '-'; i++);
if (i != 0)
memcpy(label, &label[i], len - i);
memmove(label, &label[i], len - i);
len = strlen(label);
if (len <= 1)
return -1;
Expand All @@ -1529,7 +1529,7 @@ int sanitize_label(char* label)
// Remove all duplicate '-' (non-optimized!)
for (i = 0; len >= 2 && i < len - 2; i++) {
if (label[i] == '-' && label[i + 1] == '-') {
memcpy(&label[i + 1], &label[i + 2], len - i - 1);
memmove(&label[i + 1], &label[i + 2], len - i - 1);
len--;
i--;
}
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.5.2169"
CAPTION "Rufus 4.5.2170"
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 @@ -397,8 +397,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,5,2169,0
PRODUCTVERSION 4,5,2169,0
FILEVERSION 4,5,2170,0
PRODUCTVERSION 4,5,2170,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -416,13 +416,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.5.2169"
VALUE "FileVersion", "4.5.2170"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "� 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.2169"
VALUE "ProductVersion", "4.5.2170"
END
END
BLOCK "VarFileInfo"
Expand Down
5 changes: 3 additions & 2 deletions src/vhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,9 @@ void VhdSaveImage(void)
img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, &i);
if (img_save.ImagePath == NULL)
goto out;
for (i = 1; i <= (UINT)img_ext.count && (strstr(img_save.ImagePath, &_img_ext_x[i - 1][1]) == NULL); i++);
if (i > (UINT)img_ext.count) {
// Start from the end of our extension array, since '.vhd' would match for '.vhdx' otherwise
for (i = (UINT)img_ext.count; (i > 0) && (strstr(img_save.ImagePath, &_img_ext_x[i - 1][1]) == NULL); i--);
if (i == 0) {
uprintf("Warning: Can not determine image type from extension - Saving to uncompressed VHD.");
i = image_type_vhd;
} else {
Expand Down

0 comments on commit 45423be

Please sign in to comment.