1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[cmp] update Bled to latest

* Adds the provision of default buffer size in bled_init()
This commit is contained in:
Pete Batard 2023-06-30 13:05:42 +01:00
parent c717c7789b
commit c47ee4c435
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
10 changed files with 31 additions and 20 deletions

View file

@ -31,6 +31,7 @@ jmp_buf bb_error_jmp;
char* bb_virtual_buf = NULL; char* bb_virtual_buf = NULL;
size_t bb_virtual_len = 0, bb_virtual_pos = 0; size_t bb_virtual_len = 0, bb_virtual_pos = 0;
int bb_virtual_fd = -1; int bb_virtual_fd = -1;
uint32_t BB_BUFSIZE = 0x10000;
static long long int unpack_none(transformer_state_t *xstate) static long long int unpack_none(transformer_state_t *xstate)
{ {
@ -265,7 +266,8 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
} }
/* Initialize the library. /* Initialize the library.
* When the parameters are not NULL you can: * When the parameters are not NULL or zero you can:
* - specify the buffer size to use (must be larger than 64KB and a power of two)
* - specify the printf-like function you want to use to output message * - specify the printf-like function you want to use to output message
* void print_function(const char* format, ...); * void print_function(const char* format, ...);
* - specify the read/write functions you want to use; * - specify the read/write functions you want to use;
@ -275,18 +277,25 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
* void switch_function(const char* filename, const uint64_t filesize); * void switch_function(const char* filename, const uint64_t filesize);
* - point to an unsigned long variable, to be used to cancel operations when set to non zero * - point to an unsigned long variable, to be used to cancel operations when set to non zero
*/ */
int bled_init(printf_t print_function, read_t read_function, write_t write_function, int bled_init(uint32_t buffer_size, printf_t print_function, read_t read_function, write_t write_function,
progress_t progress_function, switch_t switch_function, unsigned long* cancel_request) progress_t progress_function, switch_t switch_function, unsigned long* cancel_request)
{ {
if (bled_initialized) if (bled_initialized)
return -1; return -1;
bled_initialized = true; BB_BUFSIZE = buffer_size;
/* buffer_size must be larger than 64 KB and a power of two */
if (buffer_size < 0x10000 || (buffer_size & (buffer_size - 1)) != 0) {
if (buffer_size != 0 && print_function != NULL)
print_function("bled_init: invalid buffer_size, defaulting to 64 KB");
BB_BUFSIZE = 0x10000;
}
bled_printf = print_function; bled_printf = print_function;
bled_read = read_function; bled_read = read_function;
bled_write = write_function; bled_write = write_function;
bled_progress = progress_function; bled_progress = progress_function;
bled_switch = switch_function; bled_switch = switch_function;
bled_cancel_request = cancel_request; bled_cancel_request = cancel_request;
bled_initialized = true;
return 0; return 0;
} }

View file

@ -50,7 +50,8 @@ int64_t bled_uncompress_to_dir(const char* src, const char* dir, int type);
int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_len, char* dst, size_t dst_len, int type); int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_len, char* dst, size_t dst_len, int type);
/* Initialize the library. /* Initialize the library.
* When the parameters are not NULL you can: * When the parameters are not NULL or zero you can:
* - specify the buffer size to use (must be larger than 64KB and a power of two)
* - specify the printf-like function you want to use to output message * - specify the printf-like function you want to use to output message
* void print_function(const char* format, ...); * void print_function(const char* format, ...);
* - specify the read/write functions you want to use; * - specify the read/write functions you want to use;
@ -60,7 +61,7 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
* void switch_function(const char* filename, const uint64_t filesize); * void switch_function(const char* filename, const uint64_t filesize);
* - point to an unsigned long variable, to be used to cancel operations when set to non zero * - point to an unsigned long variable, to be used to cancel operations when set to non zero
*/ */
int bled_init(printf_t print_function, read_t read_function, write_t write_function, int bled_init(uint32_t buffer_size, printf_t print_function, read_t read_function, write_t write_function,
progress_t progress_function, switch_t switch_function, unsigned long* cancel_request); progress_t progress_function, switch_t switch_function, unsigned long* cancel_request);
/* This call frees any resource used by the library */ /* This call frees any resource used by the library */

View file

@ -45,10 +45,11 @@ typedef struct huft_t {
} v; } v;
} huft_t; } huft_t;
/* gunzip_window size--must be a power of two, and
* at least 32K for zip's deflate method */
#define GUNZIP_WSIZE BB_BUFSIZE
enum { enum {
/* gunzip_window size--must be a power of two, and
* at least 32K for zip's deflate method */
GUNZIP_WSIZE = BB_BUFSIZE,
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ /* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
BMAX = 16, /* maximum bit length of any code (16 for explode) */ BMAX = 16, /* maximum bit length of any code (16 for explode) */
N_MAX = 288, /* maximum number of codes in any set */ N_MAX = 288, /* maximum number of codes in any set */

View file

@ -27,10 +27,10 @@
/* Default input buffer size */ /* Default input buffer size */
#define IBUFSIZ BB_BUFSIZE #define IBUFSIZ ((int)BB_BUFSIZE)
/* Default output buffer size */ /* Default output buffer size */
#define OBUFSIZ BB_BUFSIZE #define OBUFSIZ ((int)BB_BUFSIZE)
/* Defines for third byte of header */ /* Defines for third byte of header */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */ #define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */

View file

@ -39,7 +39,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <io.h> #include <io.h>
#define BB_BUFSIZE 0x40000
#define ONE_TB 1099511627776ULL #define ONE_TB 1099511627776ULL
#define ENABLE_DESKTOP 1 #define ENABLE_DESKTOP 1
@ -105,6 +104,7 @@ typedef unsigned int uid_t;
#define get_le16(ptr) (*(const uint16_t *)(ptr)) #define get_le16(ptr) (*(const uint16_t *)(ptr))
#endif #endif
extern uint32_t BB_BUFSIZE;
extern smallint bb_got_signal; extern smallint bb_got_signal;
extern uint32_t *global_crc32_table; extern uint32_t *global_crc32_table;
extern jmp_buf bb_error_jmp; extern jmp_buf bb_error_jmp;

View file

@ -1290,7 +1290,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
} }
assert((uintptr_t)sec_buf % SelectedDrive.SectorSize == 0); assert((uintptr_t)sec_buf % SelectedDrive.SectorSize == 0);
sec_buf_pos = 0; sec_buf_pos = 0;
bled_init(uprintf, NULL, sector_write, update_progress, NULL, &FormatStatus); bled_init(256 * KB, uprintf, NULL, sector_write, update_progress, NULL, &FormatStatus);
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type); bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
bled_exit(); bled_exit();
uprintfs("\r\n"); uprintfs("\r\n");

View file

@ -1283,7 +1283,7 @@ out:
update_md5sum(); update_md5sum();
if (archive_path != NULL) { if (archive_path != NULL) {
uprintf("● Adding files from %s", archive_path); uprintf("● Adding files from %s", archive_path);
bled_init(NULL, NULL, NULL, NULL, alt_print_extracted_file, NULL); bled_init(256 * KB, NULL, NULL, NULL, NULL, alt_print_extracted_file, NULL);
bled_uncompress_to_dir(archive_path, dest_dir, BLED_COMPRESSION_ZIP); bled_uncompress_to_dir(archive_path, dest_dir, BLED_COMPRESSION_ZIP);
bled_exit(); bled_exit();
} }

View file

@ -948,7 +948,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
free(sig); free(sig);
uprintf("Download signature is valid ✓"); uprintf("Download signature is valid ✓");
uncompressed_size = *((uint64_t*)&compressed[5]); uncompressed_size = *((uint64_t*)&compressed[5]);
if ((uncompressed_size < 1 * MB) && (bled_init(uprintf, NULL, NULL, NULL, NULL, &FormatStatus) >= 0)) { if ((uncompressed_size < 1 * MB) && (bled_init(0, uprintf, NULL, NULL, NULL, NULL, &FormatStatus) >= 0)) {
fido_script = malloc((size_t)uncompressed_size); fido_script = malloc((size_t)uncompressed_size);
size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA); size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA);
bled_exit(); bled_exit();

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.2.2057" CAPTION "Rufus 4.2.2058"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,2,2057,0 FILEVERSION 4,2,2058,0
PRODUCTVERSION 4,2,2057,0 PRODUCTVERSION 4,2,2058,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.2.2057" VALUE "FileVersion", "4.2.2058"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.2.exe" VALUE "OriginalFilename", "rufus-4.2.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.2.2057" VALUE "ProductVersion", "4.2.2058"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -211,7 +211,7 @@ static BOOL IsCompressedBootableImage(const char* path)
if (buf == NULL) if (buf == NULL)
return FALSE; return FALSE;
FormatStatus = 0; FormatStatus = 0;
bled_init(uprintf, NULL, NULL, NULL, NULL, &FormatStatus); bled_init(0, uprintf, NULL, NULL, NULL, NULL, &FormatStatus);
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type); dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
bled_exit(); bled_exit();
if (dc != MBR_SIZE) { if (dc != MBR_SIZE) {