From 6e0e1495ca3229ef6924bc599cf8187908167f31 Mon Sep 17 00:00:00 2001 From: anders_k Date: Thu, 21 Apr 2016 23:01:29 +0000 Subject: [PATCH] Zip2Exe aborts if the zip file is encrypted git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6748 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/zip2exe/main.cpp | 16 ++++++++++++++++ Docs/src/history.but | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/Contrib/zip2exe/main.cpp b/Contrib/zip2exe/main.cpp index 13ba91ce..c843c2ba 100644 --- a/Contrib/zip2exe/main.cpp +++ b/Contrib/zip2exe/main.cpp @@ -92,6 +92,14 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int return (int) DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG1),0,DlgProc); } +static bool IsEncrypted(unz_file_info&zfi) +{ + const unsigned short gpf_encrypted = (1<< 0); // 2.0.0+ + const unsigned short gpf_encstrong = (1<< 6); // 5.0.0+ APPNOTE says that bit 0 MUST be set if bit 6 is set + const unsigned short gpf_enccntdir = (1<<13); // 6.2.0+ Central Directory Encryption + return (zfi.flag & (gpf_encrypted|gpf_enccntdir)) != 0; +} + static void doRMDir(TCHAR *buf) { HANDLE h; @@ -205,6 +213,13 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn) // ZREAD uses byte size, not TCHAR length. unzGetCurrentFileInfo(f,&info,filenameA,sizeof(filenameA),NULL,0,NULL,0); + if (IsEncrypted(info)) + { + if (f) unzClose(f); + g_extracting = 0; + MessageBox(hwndDlg,_T("Encrypted ZIP files are not supported!"),g_errcaption,MB_OK|MB_ICONSTOP); + return 1; + } // was zip created on MS-DOS/Windows? if ((info.version & 0xFF00) == 0) @@ -217,6 +232,7 @@ int tempzip_make(HWND hwndDlg, TCHAR *fn) if (MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH) == 0) { if (f) unzClose(f); + g_extracting = 0; MessageBox(hwndDlg,_T("Error converting filename to Unicode"), g_errcaption, MB_OK|MB_ICONSTOP); return 1; } diff --git a/Docs/src/history.but b/Docs/src/history.but index 305dce89..6294feb8 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -6,6 +6,10 @@ Released on ???? ?nd, 2016 \S1{v3.0rc2-cl} Changelog +\S2{} Minor Changes + +\b Zip2Exe aborts if the zip file is encrypted + \S2{} Translations \b Minor tweaks to Danish.nlf (scootergrisen) (\W{http://sf.net/p/nsis/bugs/1140}{bug #1140})