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:
		
							parent
							
								
									81673ade26
								
							
						
					
					
						commit
						a41bca3183
					
				
					 2 changed files with 30 additions and 36 deletions
				
			
		|  | @ -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) */ | /* 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) | 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 */ | 	/* Update bytecount */ | ||||||
| 	ctx->bytecount += len; | 	ctx->bytecount += len; | ||||||
| 
 | 
 | ||||||
| 	t = ctx->bytecount & 0x3f; |  | ||||||
| 
 |  | ||||||
| 	/* Handle any leading odd-sized chunks */ | 	/* Handle any leading odd-sized chunks */ | ||||||
| 	if (t) { | 	if (num) { | ||||||
| 		unsigned char *p = ctx->buf + t; | 		unsigned char *p = ctx->buf + num; | ||||||
| 
 | 
 | ||||||
| 		t = 64 - t; | 		num = 64 - num; | ||||||
| 		if (len < t) { | 		if (len < num) { | ||||||
| 			memcpy(p, buf, len); | 			memcpy(p, buf, len); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		memcpy(p, buf, t); | 		memcpy(p, buf, num); | ||||||
| 		sha1_transform(ctx, ctx->buf); | 		sha1_transform(ctx, ctx->buf); | ||||||
| 		buf += t; | 		buf += num; | ||||||
| 		len -= t; | 		len -= num; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Process data in 64-byte chunks */ | 	/* 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) */ | /* 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) | 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 */ | 	/* Update bytecount */ | ||||||
| 	ctx->bytecount += len; | 	ctx->bytecount += len; | ||||||
| 
 | 
 | ||||||
| 	t = ctx->bytecount & 0x3f; |  | ||||||
| 
 |  | ||||||
| 	/* Handle any leading odd-sized chunks */ | 	/* Handle any leading odd-sized chunks */ | ||||||
| 	if (t) { | 	if (num) { | ||||||
| 		unsigned char *p = ctx->buf + t; | 		unsigned char *p = ctx->buf + num; | ||||||
| 
 | 
 | ||||||
| 		t = 64 - t; | 		num = 64 - num; | ||||||
| 		if (len < t) { | 		if (len < num) { | ||||||
| 			memcpy(p, buf, len); | 			memcpy(p, buf, len); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		memcpy(p, buf, t); | 		memcpy(p, buf, num); | ||||||
| 		sha256_transform(ctx, ctx->buf); | 		sha256_transform(ctx, ctx->buf); | ||||||
| 		buf += t; | 		buf += num; | ||||||
| 		len -= t; | 		len -= num; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Process data in 64-byte chunks */ | 	/* 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) */ | /* 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) | 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 */ | 	/* Update bytecount */ | ||||||
| 	ctx->bytecount += len; | 	ctx->bytecount += len; | ||||||
| 
 | 
 | ||||||
| 	t = ctx->bytecount & 0x3f; |  | ||||||
| 
 |  | ||||||
| 	/* Handle any leading odd-sized chunks */ | 	/* Handle any leading odd-sized chunks */ | ||||||
| 	if (t) { | 	if (num) { | ||||||
| 		unsigned char *p = ctx->buf + t; | 		unsigned char *p = ctx->buf + num; | ||||||
| 
 | 
 | ||||||
| 		t = 64 - t; | 		num = 64 - num; | ||||||
| 		if (len < t) { | 		if (len < num) { | ||||||
| 			memcpy(p, buf, len); | 			memcpy(p, buf, num); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		memcpy(p, buf, t); | 		memcpy(p, buf, num); | ||||||
| 		md5_transform(ctx, ctx->buf); | 		md5_transform(ctx, ctx->buf); | ||||||
| 		buf += t; | 		buf += num; | ||||||
| 		len -= t; | 		len -= num; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Process data in 64-byte chunks */ | 	/* Process data in 64-byte chunks */ | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||||
| 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 2.10.937" | CAPTION "Rufus 2.10.938" | ||||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 |     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||||
|  | @ -320,8 +320,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,10,937,0 |  FILEVERSION 2,10,938,0 | ||||||
|  PRODUCTVERSION 2,10,937,0 |  PRODUCTVERSION 2,10,938,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -338,13 +338,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "2.10.937" |             VALUE "FileVersion", "2.10.938" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "2.10.937" |             VALUE "ProductVersion", "2.10.938" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue