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

[ui] fix potentially truncated SHA1 sum field

* Also update licensing terms
* Closes #577
This commit is contained in:
Pete Batard 2015-08-22 15:57:23 +01:00
parent fb09802c0f
commit 7943f77914
4 changed files with 56 additions and 13 deletions

View file

@ -19,13 +19,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* SHA-1 code taken from GnuPG */
/* MD5 code taken from Asterisk */
/*
* SHA-1 code taken from GnuPG, as per copyrights above.
*
* MD5 code from various public domain sources sharing the following
* copyright declaration:
*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
#include <windowsx.h>
#include "msapi_utf8.h"
#include "rufus.h"
#include "resource.h"
@ -523,7 +544,8 @@ static void md5_final(MD5_CONTEXT *ctx)
*/
INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int i;
int i, dw;
RECT rect;
HFONT hFont;
HDC hDC;
@ -540,6 +562,19 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
SendDlgItemMessageA(hDlg, IDC_SHA1, WM_SETFONT, (WPARAM)hFont, TRUE);
SetWindowTextA(GetDlgItem(hDlg, IDC_MD5), md5str);
SetWindowTextA(GetDlgItem(hDlg, IDC_SHA1), sha1str);
// Move/Resize the controls as needed to fit our text
hDC = GetDC(GetDlgItem(hDlg, IDC_SHA1));
SelectFont(hDC, hFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, sha1str, -1, &rect, DT_CALCRECT);
if (hDC != NULL)
ReleaseDC(GetDlgItem(hDlg, IDC_SHA1), hDC);
dw = rect.right - rect.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
for (i=(int)safe_strlen(image_path); (i>0)&&(image_path[i]!='\\'); i--);
if (image_path != NULL) // VS code analysis has a false positive on this one
SetWindowTextU(hDlg, &image_path[i+1]);

View file

@ -101,6 +101,13 @@ const char* additional_copyrights =
"http://kolibrios.org\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"MD5 checksum by Ron Rivest, Colin Plumb et al.\\line\n"
"Public Domain\\line\n"
"\\line\n"
"SHA-1 checksum from GnuPG:\\line\n"
"https://www.gnupg.org\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"
"\\line\n"
"About and License dialogs inspired by WinSCP by Martin Prikryl\\line\n"
"http://winscp.net\\line\n"
"GNU General Public License (GPL) v3 or later\\line\n"

View file

@ -32,7 +32,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
CAPTION "Rufus 2.3.700"
CAPTION "Rufus 2.3.701"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -317,8 +317,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,3,700,0
PRODUCTVERSION 2,3,700,0
FILEVERSION 2,3,701,0
PRODUCTVERSION 2,3,701,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -335,13 +335,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.3.700"
VALUE "FileVersion", "2.3.701"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.3.700"
VALUE "ProductVersion", "2.3.701"
END
END
BLOCK "VarFileInfo"

View file

@ -821,7 +821,7 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA
RECT rect;
HFONT hDlgFont;
HWND hCtrl;
HDC dc;
HDC hDC;
switch (message) {
case WM_INITDIALOG:
@ -861,13 +861,14 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA
// Move/Resize the controls as needed to fit our text
hCtrl = GetDlgItem(hDlg, IDC_SELECTION_TEXT);
dc = GetDC(hCtrl);
SelectFont(dc, hDlgFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
hDC = GetDC(hCtrl);
SelectFont(hDC, hDlgFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(hCtrl, &rect);
dh = rect.bottom - rect.top;
DrawTextU(dc, szMessageText, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
DrawTextU(hDC, szMessageText, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
dh = rect.bottom - rect.top - dh;
ReleaseDC(hCtrl, dc);
if (hDC != NULL)
ReleaseDC(hCtrl, hDC);
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh, 1.0f);