[Midnightbsd-cvs] mports [20962] trunk/archivers/p7zip: security update for p7zip 15.09

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Feb 2 23:03:47 EST 2016


Revision: 20962
          http://svnweb.midnightbsd.org/mports/?rev=20962
Author:   laffer1
Date:     2016-02-02 23:03:47 -0500 (Tue, 02 Feb 2016)
Log Message:
-----------
security update for p7zip 15.09

Modified Paths:
--------------
    trunk/archivers/p7zip/Makefile
    trunk/archivers/p7zip/distinfo
    trunk/archivers/p7zip/files/patch-CPP-Windows-System.cpp
    trunk/archivers/p7zip/pkg-plist

Added Paths:
-----------
    trunk/archivers/p7zip/files/patch-CVE-2015-1038

Modified: trunk/archivers/p7zip/Makefile
===================================================================
--- trunk/archivers/p7zip/Makefile	2016-02-03 03:46:42 UTC (rev 20961)
+++ trunk/archivers/p7zip/Makefile	2016-02-03 04:03:47 UTC (rev 20962)
@@ -1,8 +1,7 @@
 # $MidnightBSD$
 
 PORTNAME=	p7zip
-PORTVERSION=	9.38.1
-PORTREVISION?=	0
+PORTVERSION=	15.09
 CATEGORIES=	archivers
 MASTER_SITES=	SF
 DISTNAME=	${PORTNAME}_${DISTVERSION}_src_all
@@ -25,6 +24,8 @@
 
 OPTIONS_DEFINE=	DOCS
 
+PORTDOCS=	*
+
 post-patch:
 	${SED} -e 's!g\+\+!${CXX}!' \
 	       -e 's!gcc!${CC}!' \

Modified: trunk/archivers/p7zip/distinfo
===================================================================
--- trunk/archivers/p7zip/distinfo	2016-02-03 03:46:42 UTC (rev 20961)
+++ trunk/archivers/p7zip/distinfo	2016-02-03 04:03:47 UTC (rev 20962)
@@ -1,2 +1,2 @@
-SHA256 (p7zip_9.38.1_src_all.tar.bz2) = fd5019109c9a1bf34ad3257d37a6853eae8151ff50345f0a3ffba7d8c5fdb995
-SIZE (p7zip_9.38.1_src_all.tar.bz2) = 3917925
+SHA256 (p7zip_15.09_src_all.tar.bz2) = 8783acf747e210e00150f7311cc06c4cd8ecf7b0c27b4adf2194284cc49b4d6f
+SIZE (p7zip_15.09_src_all.tar.bz2) = 4048481

Modified: trunk/archivers/p7zip/files/patch-CPP-Windows-System.cpp
===================================================================
--- trunk/archivers/p7zip/files/patch-CPP-Windows-System.cpp	2016-02-03 03:46:42 UTC (rev 20961)
+++ trunk/archivers/p7zip/files/patch-CPP-Windows-System.cpp	2016-02-03 04:03:47 UTC (rev 20962)
@@ -1,11 +1,11 @@
---- CPP/Windows/System.cpp.orig	2008-09-07 02:29:34.000000000 +0800
-+++ CPP/Windows/System.cpp	2008-09-07 02:30:23.000000000 +0800
-@@ -44,7 +44,7 @@
+--- CPP/Windows/System.cpp.orig	2015-09-26 08:47:01 UTC
++++ CPP/Windows/System.cpp
+@@ -44,7 +44,7 @@ namespace NWindows
  		#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
  		UInt32 GetNumberOfProcessors() {
  		  	int nbcpu = 1;
 -			size_t value;
-+		  	int value;
++			int value;
  			size_t len = sizeof(value);
  			if (sysctlbyname("hw.ncpu", &value, &len, NULL, 0) == 0)
  				nbcpu = value;

Added: trunk/archivers/p7zip/files/patch-CVE-2015-1038
===================================================================
--- trunk/archivers/p7zip/files/patch-CVE-2015-1038	                        (rev 0)
+++ trunk/archivers/p7zip/files/patch-CVE-2015-1038	2016-02-03 04:03:47 UTC (rev 20962)
@@ -0,0 +1,283 @@
+Author: Ben Hutchings <ben at decadent.org.uk>
+Date: Tue, 19 May 2015 02:38:40 +0100
+Description: Delay creation of symlinks to prevent arbitrary file writes (CVE-2015-1038)
+Bug: http://sourceforge.net/p/p7zip/bugs/147/
+Bug-Debian: https://bugs.debian.org/774660
+
+Alexander Cherepanov discovered that 7zip is susceptible to a
+directory traversal vulnerability.  While extracting an archive, it
+will extract symlinks and then follow them if they are referenced in
+further entries.  This can be exploited by a rogue archive to write
+files outside the current directory.
+
+We have to create placeholder files (which we already do) and delay
+creating symlinks until the end of extraction.
+
+Due to the possibility of anti-items (deletions) in the archive, it is
+possible for placeholders to be deleted and replaced before we create
+the symlinks.  It's not clear that this can be used for mischief, but
+GNU tar guards against similar problems by checking that the placeholder
+still exists and is the same inode.  XXX It also checks 'birth time' but
+this isn't portable.  We can probably get away with comparing ctime
+since we don't support hard links.
+
+--- CPP/7zip/UI/Agent/Agent.cpp.orig	2015-09-17 19:02:35 UTC
++++ CPP/7zip/UI/Agent/Agent.cpp
+@@ -1515,7 +1515,7 @@ STDMETHODIMP CAgentFolder::Extract(const
+   HRESULT result = _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+       realIndices.Size(), testMode, extractCallback);
+   if (result == S_OK)
+-    result = extractCallbackSpec->SetDirsTimes();
++    result = extractCallbackSpec->SetFinalAttribs();
+   return result;
+   COM_TRY_END
+ }
+--- CPP/7zip/UI/Client7z/Client7z.cpp.orig	2015-10-17 14:52:30 UTC
++++ CPP/7zip/UI/Client7z/Client7z.cpp
+@@ -230,8 +230,11 @@ private:
+   COutFileStream *_outFileStreamSpec;
+   CMyComPtr<ISequentialOutStream> _outFileStream;
+ 
++  CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks;
++
+ public:
+   void Init(IInArchive *archiveHandler, const FString &directoryPath);
++  HRESULT SetFinalAttribs();
+ 
+   UInt64 NumErrors;
+   bool PasswordIsDefined;
+@@ -449,11 +452,23 @@ STDMETHODIMP CArchiveExtractCallback::Se
+   }
+   _outFileStream.Release();
+   if (_extractMode && _processedFileInfo.AttribDefined)
+-    SetFileAttrib(_diskFilePath, _processedFileInfo.Attrib);
++    SetFileAttrib(_diskFilePath, _processedFileInfo.Attrib, &_delayedSymLinks);
+   PrintNewLine();
+   return S_OK;
+ }
+ 
++HRESULT CArchiveExtractCallback::SetFinalAttribs()
++{
++  HRESULT result = S_OK;
++
++  for (int i = 0; i != _delayedSymLinks.Size(); ++i)
++    if (!_delayedSymLinks[i].Create())
++      result = E_FAIL;
++
++  _delayedSymLinks.Clear();
++
++  return result;
++}
+ 
+ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
+ {
+@@ -914,6 +929,8 @@ int MY_CDECL main(int numArgs, const cha
+       // extractCallbackSpec->PasswordIsDefined = true;
+       // extractCallbackSpec->Password = L"1";
+       HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
++      if (result == S_OK)
++	result = extractCallbackSpec->SetFinalAttribs();
+       if (result != S_OK)
+       {
+         PrintError("Extract Error");
+--- CPP/7zip/UI/Common/ArchiveExtractCallback.cpp.orig	2015-10-03 08:49:15 UTC
++++ CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+@@ -1502,7 +1502,7 @@ STDMETHODIMP CArchiveExtractCallback::Se
+     NumFiles++;
+ 
+   if (!_stdOutMode && _extractMode && _fi.AttribDefined)
+-    SetFileAttrib(_diskFilePath, _fi.Attrib);
++    SetFileAttrib(_diskFilePath, _fi.Attrib, &_delayedSymLinks);
+   
+   RINOK(_extractCallback2->SetOperationResult(opRes, BoolToInt(_encrypted)));
+   
+@@ -1584,8 +1584,9 @@ static unsigned GetNumSlashes(const FCha
+   }
+ }
+ 
+-HRESULT CArchiveExtractCallback::SetDirsTimes()
++HRESULT CArchiveExtractCallback::SetFinalAttribs()
+ {
++  HRESULT result = S_OK;
+   CRecordVector<CExtrRefSortPair> pairs;
+   pairs.ClearAndSetSize(_extractedFolderPaths.Size());
+   unsigned i;
+@@ -1622,5 +1623,12 @@ HRESULT CArchiveExtractCallback::SetDirs
+       (WriteATime && ATimeDefined) ? &ATime : NULL,
+       (WriteMTime && MTimeDefined) ? &MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
+   }
+-  return S_OK;
++
++  for (int i = 0; i != _delayedSymLinks.Size(); ++i)
++    if (!_delayedSymLinks[i].Create())
++      result = E_FAIL;
++
++  _delayedSymLinks.Clear();
++
++  return result;
+ }
+--- CPP/7zip/UI/Common/ArchiveExtractCallback.h.orig	2015-10-03 10:29:09 UTC
++++ CPP/7zip/UI/Common/ArchiveExtractCallback.h
+@@ -6,6 +6,8 @@
+ #include "../../../Common/MyCom.h"
+ #include "../../../Common/Wildcard.h"
+ 
++#include "../../../Windows/FileDir.h"
++
+ #include "../../IPassword.h"
+ 
+ #include "../../Common/FileStreams.h"
+@@ -237,6 +239,8 @@ class CArchiveExtractCallback:
+   bool _saclEnabled;
+   #endif
+ 
++  CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks;
++
+   void CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath);
+   HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
+   HRESULT GetUnpackSize();
+@@ -330,7 +334,7 @@ public:
+   }
+   #endif
+ 
+-  HRESULT SetDirsTimes();
++  HRESULT SetFinalAttribs();
+ };
+ 
+ bool CensorNode_CheckPath(const NWildcard::CCensorNode &node, const CReadArcItem &item);
+--- CPP/7zip/UI/Common/Extract.cpp.orig	2015-09-07 19:47:32 UTC
++++ CPP/7zip/UI/Common/Extract.cpp
+@@ -207,7 +207,7 @@ static HRESULT DecompressArchive(
+   else
+     result = archive->Extract(&realIndices.Front(), realIndices.Size(), testMode, ecs);
+   if (result == S_OK && !options.StdInMode)
+-    result = ecs->SetDirsTimes();
++    result = ecs->SetFinalAttribs();
+   return callback->ExtractResult(result);
+ }
+ 
+--- CPP/Windows/FileDir.cpp.orig	2015-10-10 12:37:41 UTC
++++ CPP/Windows/FileDir.cpp
+@@ -347,7 +347,8 @@ static int convert_to_symlink(const char
+   return -1;
+ }
+ 
+-bool SetFileAttrib(CFSTR fileName, DWORD fileAttributes)
++bool SetFileAttrib(CFSTR fileName, DWORD fileAttributes,
++		   CObjectVector<CDelayedSymLink> *delayedSymLinks)
+ {
+   if (!fileName) {
+     SetLastError(ERROR_PATH_NOT_FOUND);
+@@ -379,7 +380,9 @@ bool SetFileAttrib(CFSTR fileName, DWORD
+      stat_info.st_mode = fileAttributes >> 16;
+ #ifdef ENV_HAVE_LSTAT
+      if (S_ISLNK(stat_info.st_mode)) {
+-        if ( convert_to_symlink(name) != 0) {
++        if (delayedSymLinks)
++          delayedSymLinks->Add(CDelayedSymLink(name));
++        else if ( convert_to_symlink(name) != 0) {
+           TRACEN((printf("SetFileAttrib(%s,%d) : false-3\n",(const char *)name,fileAttributes)))
+           return false;
+         }
+@@ -814,6 +817,43 @@ bool CTempDir::Remove()
+   return !_mustBeDeleted;
+ }
+ 
++#ifdef ENV_UNIX
++
++CDelayedSymLink::CDelayedSymLink(const char * source)
++  : _source(source)
++{
++  struct stat st;
++
++  if (lstat(_source, &st) == 0) {
++    _dev = st.st_dev;
++    _ino = st.st_ino;
++  } else {
++    _dev = 0;
++  }
++}
++
++bool CDelayedSymLink::Create()
++{
++  struct stat st;
++
++  if (_dev == 0) {
++    errno = EPERM;
++    return false;
++  }
++  if (lstat(_source, &st) != 0)
++    return false;
++  if (_dev != st.st_dev || _ino != st.st_ino) {
++    // Placeholder file has been overwritten or moved by another
++    // symbolic link creation
++    errno = EPERM;
++    return false;
++  }
++
++  return convert_to_symlink(_source) == 0;
++}
++
++#endif // ENV_UNIX
++
+ }}}
+ 
+ #ifndef _SFX
+--- CPP/Windows/FileDir.h.orig	2015-06-19 10:52:06 UTC
++++ CPP/Windows/FileDir.h
+@@ -4,6 +4,7 @@
+ #define __WINDOWS_FILE_DIR_H
+ 
+ #include "../Common/MyString.h"
++#include "../Common/MyVector.h"
+ 
+ #include "FileIO.h"
+ 
+@@ -11,11 +12,14 @@ namespace NWindows {
+ namespace NFile {
+ namespace NDir {
+ 
++class CDelayedSymLink;
++
+ bool GetWindowsDir(FString &path);
+ bool GetSystemDir(FString &path);
+ 
+ bool SetDirTime(CFSTR path, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime);
+-bool SetFileAttrib(CFSTR path, DWORD attrib);
++bool SetFileAttrib(CFSTR path, DWORD attrib,
++		   CObjectVector<CDelayedSymLink> *delayedSymLinks = 0);
+ bool MyMoveFile(CFSTR existFileName, CFSTR newFileName);
+ 
+ #ifndef UNDER_CE
+@@ -76,6 +80,31 @@ public:
+   bool Remove();
+ };
+ 
++// Symbolic links must be created last so that they can't be used to
++// create or overwrite files above the extraction directory.
++class CDelayedSymLink
++{
++#ifdef ENV_UNIX
++  // Where the symlink should be created.  The target is specified in
++  // the placeholder file.
++  AString _source;
++
++  // Device and inode of the placeholder file.  Before creating the
++  // symlink, we must check that these haven't been changed by creation
++  // of another symlink.
++  dev_t _dev;
++  ino_t _ino;
++
++public:
++  explicit CDelayedSymLink(const char * source);
++  bool Create();
++#else // !ENV_UNIX
++public:
++  CDelayedSymLink(const char * source) {}
++  bool Create() { return true; }
++#endif // ENV_UNIX
++};
++
+ #if !defined(UNDER_CE)
+ class CCurrentDirRestorer
+ {


Property changes on: trunk/archivers/p7zip/files/patch-CVE-2015-1038
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/archivers/p7zip/pkg-plist
===================================================================
--- trunk/archivers/p7zip/pkg-plist	2016-02-03 03:46:42 UTC (rev 20961)
+++ trunk/archivers/p7zip/pkg-plist	2016-02-03 04:03:47 UTC (rev 20962)
@@ -9,61 +9,3 @@
 man/man1/7z.1.gz
 man/man1/7za.1.gz
 man/man1/7zr.1.gz
-%%PORTDOCS%%%%DOCSDIR%%/7zC.txt
-%%PORTDOCS%%%%DOCSDIR%%/7zFormat.txt
-%%PORTDOCS%%%%DOCSDIR%%/License.txt
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/add.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/bench.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/delete.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/extract.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/extract_full.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/hash.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/index.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/list.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/rename.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/style.css
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/test.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/commands/update.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/exit_codes.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/index.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/style.css
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/ar_exclude.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/ar_include.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/ar_no.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/charset.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/exclude.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/include.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/index.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/large_pages.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/list_tech.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/method.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/output_dir.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/overwrite.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/password.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/recurse.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/sa.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/scrc.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/sdel.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/sfx.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/sni.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/sns.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/spf.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/ssc.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/stdin.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/stdout.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/stl.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/stop_switch.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/style.css
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/type.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/update.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/volume.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/working_dir.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/switches/yes.htm
-%%PORTDOCS%%%%DOCSDIR%%/MANUAL/syntax.htm
-%%PORTDOCS%%%%DOCSDIR%%/Methods.txt
-%%PORTDOCS%%%%DOCSDIR%%/copying.txt
-%%PORTDOCS%%%%DOCSDIR%%/lzma.txt
-%%PORTDOCS%%%%DOCSDIR%%/readme.txt
-%%PORTDOCS%%%%DOCSDIR%%/readme.unix
-%%PORTDOCS%%%%DOCSDIR%%/src-history.txt
-%%PORTDOCS%%%%DOCSDIR%%/unRarLicense.txt



More information about the Midnightbsd-cvs mailing list