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

[checksum] fix wrong checksums for content that isn't a multiple of 64 bytes

* Leading odd-sized chunks needs to be tested *before* updating the bytecount
* Closes #761
This commit is contained in:
Pete Batard 2016-05-24 11:48:10 +01:00
parent 81673ade26
commit a41bca3183
2 changed files with 30 additions and 36 deletions

View file

@ -453,26 +453,24 @@ static void md5_transform(SUM_CONTEXT *ctx, const unsigned char *data)
/* Update the message digest with the contents of the buffer (SHA-1) */
static void sha1_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
size_t t;
size_t num = ctx->bytecount & 0x3f;
/* Update bytecount */
ctx->bytecount += len;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = ctx->buf + t;
if (num) {
unsigned char *p = ctx->buf + num;
t = 64 - t;
if (len < t) {
num = 64 - num;
if (len < num) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
memcpy(p, buf, num);
sha1_transform(ctx, ctx->buf);
buf += t;
len -= t;
buf += num;
len -= num;
}
/* Process data in 64-byte chunks */
@ -490,26 +488,24 @@ static void sha1_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
/* Update the message digest with the contents of the buffer (SHA-256) */
static void sha256_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
size_t t;
size_t num = ctx->bytecount & 0x3f;
/* Update bytecount */
ctx->bytecount += len;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = ctx->buf + t;
if (num) {
unsigned char *p = ctx->buf + num;
t = 64 - t;
if (len < t) {
num = 64 - num;
if (len < num) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
memcpy(p, buf, num);
sha256_transform(ctx, ctx->buf);
buf += t;
len -= t;
buf += num;
len -= num;
}
/* Process data in 64-byte chunks */
@ -527,26 +523,24 @@ static void sha256_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
/* Update the message digest with the contents of the buffer (MD5) */
static void md5_write(SUM_CONTEXT *ctx, const unsigned char *buf, size_t len)
{
size_t t;
size_t num = ctx->bytecount & 0x3f;
/* Update bytecount */
ctx->bytecount += len;
t = ctx->bytecount & 0x3f;
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = ctx->buf + t;
if (num) {
unsigned char *p = ctx->buf + num;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
num = 64 - num;
if (len < num) {
memcpy(p, buf, num);
return;
}
memcpy(p, buf, t);
memcpy(p, buf, num);
md5_transform(ctx, ctx->buf);
buf += t;
len -= t;
buf += num;
len -= num;
}
/* Process data in 64-byte chunks */

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.10.937"
CAPTION "Rufus 2.10.938"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -320,8 +320,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,10,937,0
PRODUCTVERSION 2,10,937,0
FILEVERSION 2,10,938,0
PRODUCTVERSION 2,10,938,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -338,13 +338,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.10.937"
VALUE "FileVersion", "2.10.938"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.10.937"
VALUE "ProductVersion", "2.10.938"
END
END
BLOCK "VarFileInfo"