mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[extfs] fix inodes not being initialized above 4 GB
* So, as it happens, when assigning the product of two 32-bit variables into a 64-bit one, compilers default to being *DUMB* and, against all reasonable expectations, do not perform that multiplication as a 64-bit operation (even when the code is compiled as x64). Wow, that's really great decision making by compiler designers if I ever saw some... Whoever decided that C developers would much rather want truncation and 32-bit overflows, instead of the expected *LOGICAL* behaviour of conducting arithmetic operations as 64-bit when the result will be assigned to a 64-bit variable, need to be condemned to a lifetime of trying to help elderly folks trying to conduct simple computing tasks as a punishment... Anyhoo, nt_write_blk()'s offset.QuadPart = block * channel->block_size + nt_data->offset was overflowing 32-bit as soon as block * channel->block_size went over the 4 GB mark, with the disastrous results one can expect. Considering that this is code we practically lifted verbatim from e2fsprogs, I guess e2fsprogs' NT I/O manager was never properly tested with anything larger than a 4 GB. Awesome! * We fix the above by doing what unix_io.c does and setting the 32-bit read/write_blk() calls to be wrappers around their 64-bit counterpart (since, once you deal with a 64-bit block variable, the computation is conducted as 64-bit). * Also remove a bunch of stuff we don't need from config.h * Closes #1396
This commit is contained in:
parent
9edd7492db
commit
67d324f82b
4 changed files with 21 additions and 19 deletions
|
@ -3,10 +3,6 @@
|
|||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#define ENABLE_NLS 0
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
|
@ -207,12 +203,6 @@
|
|||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* If the compiler supports a TLS storage class define it to that here */
|
||||
#define TLS __thread
|
||||
|
||||
/* Define if the POSIX multithreading library can be used. */
|
||||
#define USE_POSIX_THREADS 1
|
||||
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
|
|
|
@ -76,7 +76,9 @@ static errcode_t nt_open(const char *name, int flags, io_channel *channel);
|
|||
static errcode_t nt_close(io_channel channel);
|
||||
static errcode_t nt_set_blksize(io_channel channel, int blksize);
|
||||
static errcode_t nt_read_blk(io_channel channel, unsigned long block, int count, void *data);
|
||||
static errcode_t nt_read_blk64(io_channel channel, unsigned long long block, int count, void* data);
|
||||
static errcode_t nt_write_blk(io_channel channel, unsigned long block, int count, const void *data);
|
||||
static errcode_t nt_write_blk64(io_channel channel, unsigned long long block, int count, const void* data);
|
||||
static errcode_t nt_flush(io_channel channel);
|
||||
|
||||
static struct struct_io_manager struct_nt_manager = {
|
||||
|
@ -86,7 +88,9 @@ static struct struct_io_manager struct_nt_manager = {
|
|||
.close = nt_close,
|
||||
.set_blksize = nt_set_blksize,
|
||||
.read_blk = nt_read_blk,
|
||||
.read_blk64 = nt_read_blk64,
|
||||
.write_blk = nt_write_blk,
|
||||
.write_blk64 = nt_write_blk64,
|
||||
.flush = nt_flush
|
||||
};
|
||||
|
||||
|
@ -620,7 +624,7 @@ static errcode_t nt_set_blksize(io_channel channel, int blksize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static errcode_t nt_read_blk(io_channel channel, unsigned long block, int count, void *buf)
|
||||
static errcode_t nt_read_blk64(io_channel channel, unsigned long long block, int count, void *buf)
|
||||
{
|
||||
PVOID read_buffer;
|
||||
ULONG read_size;
|
||||
|
@ -671,7 +675,12 @@ static errcode_t nt_read_blk(io_channel channel, unsigned long block, int count,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static errcode_t nt_write_blk(io_channel channel, unsigned long block, int count, const void *buf)
|
||||
static errcode_t nt_read_blk(io_channel channel, unsigned long block, int count, void* buf)
|
||||
{
|
||||
return nt_read_blk64(channel, block, count, buf);
|
||||
}
|
||||
|
||||
static errcode_t nt_write_blk64(io_channel channel, unsigned long long block, int count, const void *buf)
|
||||
{
|
||||
ULONG write_size;
|
||||
LARGE_INTEGER offset;
|
||||
|
@ -718,6 +727,11 @@ static errcode_t nt_write_blk(io_channel channel, unsigned long block, int count
|
|||
return 0;
|
||||
}
|
||||
|
||||
static errcode_t nt_write_blk(io_channel channel, unsigned long block, int count, const void* buf)
|
||||
{
|
||||
return nt_write_blk64(channel, block, count, buf);
|
||||
}
|
||||
|
||||
static errcode_t nt_flush(io_channel channel)
|
||||
{
|
||||
PNT_PRIVATE_DATA nt_data = NULL;
|
||||
|
|
|
@ -376,8 +376,6 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP
|
|||
goto out;
|
||||
}
|
||||
|
||||
// TODO: mke2fs appears to be zeroing some data at the end of the partition as well
|
||||
|
||||
ext2_percent_start = 0.0f;
|
||||
ext2_percent_share = (FSName[3] == '2') ? 1.0f : 0.5f;
|
||||
uprintf("Creating %d inode sets: [1 marker = %0.1f set(s)]", ext2fs->group_desc_count,
|
||||
|
|
10
src/rufus.rc
10
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 3.9.1605"
|
||||
CAPTION "Rufus 3.9.1606"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -394,8 +394,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,9,1605,0
|
||||
PRODUCTVERSION 3,9,1605,0
|
||||
FILEVERSION 3,9,1606,0
|
||||
PRODUCTVERSION 3,9,1606,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -413,13 +413,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.9.1605"
|
||||
VALUE "FileVersion", "3.9.1606"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-3.9.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.9.1605"
|
||||
VALUE "ProductVersion", "3.9.1606"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue