View Issue Details

IDProjectCategoryView StatusLast Update
0000549PluginsMultiArc (old)public2008-06-09 07:55
ReporterDiRTy_GaRRy Assigned Toalexy  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86OSWindowsOS Version2003 SP2
Product Version1.71 
Fixed in Version1.71 
Summary0000549: Zip.fmt не поддерживает zip архивы размером более 2Гб
DescriptionZip.fmt не поддерживает просмотр листинга для zip-архивов размером более 2Гб. Появляется ошибка о неожиданном конце файла.

Патч прилагаю.
TagsNo tags attached.

Activities

2008-06-09 03:39

 

zip.patch (4,942 bytes)   
Index: plugins/multiarc/zip.cpp
===================================================================
--- plugins/multiarc/zip.cpp	(revision 1774)
+++ plugins/multiarc/zip.cpp	(working copy)
@@ -4,7 +4,7 @@
   Second-level plugin module for FAR Manager and MultiArc plugin
 
   Copyright (c) 1996-2000 Eugene Roshal
-  Copyrigth (c) 2000-2006 FAR group
+  Copyrigth (c) 2000-2008 FAR group
 */
 
 #include <windows.h>
@@ -58,9 +58,18 @@
 #endif
 */
 
+union _DWORD64
+{
+  DWORD64 Value;
+  struct
+  {
+    DWORD Low;
+    DWORD High;
+  };
+};
 
 static HANDLE ArcHandle;
-static DWORD SFXSize,NextPosition,FileSize;
+static _DWORD64 SFXSize,NextPosition,FileSize;
 static int ArcComment,Truncated,FirstRecord;
 
 struct ZipHeader
@@ -96,7 +105,7 @@
 {
   if (DataSize>=4 && Data[0]=='P' && Data[1]=='K' && Data[2]==5 && Data[3]==6)
   {
-    SFXSize=0;
+    SFXSize.Value=0;
     return(TRUE);
   }
   if (DataSize<(int)MIN_HEADER_LEN) return FALSE;
@@ -106,7 +115,7 @@
   {
     if (IsValidHeader(CurData, DataEnd))
     {
-      SFXSize=(DWORD)(CurData-Data);
+      SFXSize.Value=(DWORD)(CurData-Data);
       return(TRUE);
     }
   }
@@ -125,35 +134,43 @@
   ArcComment=FALSE;
   FirstRecord=TRUE;
 
-  FileSize=GetFileSize(ArcHandle,NULL);
+  FileSize.Low=GetFileSize(ArcHandle,&FileSize.High);
+  if (FileSize.Low==(DWORD)INVALID_HANDLE_VALUE && GetLastError()!=ERROR_SUCCESS)
+    return(FALSE);
 
   char ReadBuf[1024];
-  DWORD CurPos,ReadSize;
+  _DWORD64 CurPos; CurPos.Value=0;
+  DWORD ReadSize;
   int Buf,Found=0;
-  CurPos=NextPosition=SetFilePointer(ArcHandle,0,NULL,FILE_END);
-  if (CurPos<sizeof(ReadBuf)-18)
-    CurPos=0;
+  CurPos.Low=SetFilePointer(ArcHandle,0,(PLONG)&CurPos.High,FILE_END);
+  NextPosition=CurPos;
+  if (CurPos.Value<sizeof(ReadBuf)-18)
+    CurPos.Value=0;
   else
-    CurPos-=sizeof(ReadBuf)-18;
+    CurPos.Value-=sizeof(ReadBuf)-18;
   for (Buf=0;Buf<64 && !Found;Buf++)
   {
-    SetFilePointer(ArcHandle,CurPos,NULL,FILE_BEGIN);
+    _DWORD64 CurPosTemp=CurPos;
+    SetFilePointer(ArcHandle,CurPosTemp.Low,(PLONG)&CurPosTemp.High,FILE_BEGIN);
     ReadFile(ArcHandle,ReadBuf,sizeof(ReadBuf),&ReadSize,NULL);
     for (int I=ReadSize-4;I>=0;I--)
       if (ReadBuf[I]==0x50 && ReadBuf[I+1]==0x4b && ReadBuf[I+2]==0x05 &&
           ReadBuf[I+3]==0x06)
       {
-        SetFilePointer(ArcHandle,CurPos+I+16,NULL,FILE_BEGIN);
-        ReadFile(ArcHandle,&NextPosition,sizeof(NextPosition),&ReadSize,NULL);
+        CurPosTemp=CurPos;
+        CurPosTemp.Value+=I+16;
+        SetFilePointer(ArcHandle,CurPosTemp.Low,(PLONG)&CurPosTemp.High,FILE_BEGIN);
+        ReadFile(ArcHandle,&NextPosition.Low,sizeof(NextPosition.Low),&ReadSize,NULL);
+        NextPosition.High = 0;
         Found=TRUE;
         break;
       }
-    if (CurPos==0)
+    if (CurPos.Value==0)
       break;
-    if (CurPos<sizeof(ReadBuf)-4)
-      CurPos=0;
+    if (CurPos.Value<sizeof(ReadBuf)-4)
+      CurPos.Value=0;
     else
-      CurPos-=sizeof(ReadBuf)-4;
+      CurPos.Value-=sizeof(ReadBuf)-4;
   }
   Truncated=!Found;
   if (Truncated)
@@ -203,10 +220,10 @@
 
   DWORD ReadSize;
 
-  NextPosition=SetFilePointer(ArcHandle,NextPosition,NULL,FILE_BEGIN);
-  if (NextPosition==0xFFFFFFFF)
+  NextPosition.Low=SetFilePointer(ArcHandle,NextPosition.Low,(PLONG)&NextPosition.High,FILE_BEGIN);
+  if (NextPosition.Low==(DWORD)INVALID_SET_FILE_POINTER && GetLastError()!=ERROR_SUCCESS)
     return(GETARC_READERROR);
-  if (NextPosition>FileSize)
+  if (NextPosition.Value>FileSize.Value)
     return(GETARC_UNEXPEOF);
   if (Truncated)
   {
@@ -230,10 +247,11 @@
     {
       if (FirstRecord)
       {
-        if (SFXSize>0)
+        if (SFXSize.Value>0)
         {
-          NextPosition+=SFXSize;
-          SetFilePointer(ArcHandle,NextPosition,NULL,FILE_BEGIN);
+          NextPosition.Value+=SFXSize.Value;
+          _DWORD64 NextPositionTemp=NextPosition;
+          SetFilePointer(ArcHandle,NextPositionTemp.Low,(PLONG)&NextPositionTemp.High,FILE_BEGIN);
           if (!ReadFile(ArcHandle,&ZipHeader,sizeof(ZipHeader),&ReadSize,NULL))
             return(GETARC_READERROR);
         }
@@ -400,7 +418,7 @@
   long SeekLen=0;
   if (Truncated)
     SeekLen+=ZipHeader.PackSize;
-  NextPosition=SetFilePointer(ArcHandle,SeekLen,NULL,FILE_CURRENT);
+  NextPosition.Low=SetFilePointer(ArcHandle,SeekLen,(PLONG)&NextPosition.High,FILE_CURRENT);
 
   return(GETARC_SUCCESS);
 }
@@ -410,7 +428,7 @@
 {
   if(Info)
   {
-    Info->SFXSize=SFXSize;
+    Info->SFXSize=SFXSize.Value;
     Info->Comment=ArcComment;
   }
   return(CloseHandle(ArcHandle));
@@ -418,7 +436,7 @@
 
 DWORD WINAPI _export GetSFXPos(void)
 {
-  return SFXSize;
+  return SFXSize.Value;
 }
 
 BOOL WINAPI _export GetFormatName(int Type,char *FormatName,char *DefaultExt)
zip.patch (4,942 bytes)   

alexy

2008-06-09 07:32

administrator   bugnote:0001565

я маленько перелопатил щоб сильно по 9x не било :)
Проверяй на svn(zip 1.30)

DiRTy_GaRRy

2008-06-09 07:44

developer   bugnote:0001566

Вроде, работает. А про 9x я уже давно перестал задумываться. ;-)

Issue History

Date Modified Username Field Change
2008-06-09 03:39 DiRTy_GaRRy New Issue
2008-06-09 03:39 DiRTy_GaRRy File Added: zip.patch
2008-06-09 04:39 alexy Status new => assigned
2008-06-09 04:39 alexy Assigned To => alexy
2008-06-09 07:32 alexy Note Added: 0001565
2008-06-09 07:32 alexy Status assigned => feedback
2008-06-09 07:44 DiRTy_GaRRy Note Added: 0001566
2008-06-09 07:44 DiRTy_GaRRy Status feedback => resolved
2008-06-09 07:44 DiRTy_GaRRy Resolution open => fixed
2008-06-09 07:55 alexy Status resolved => closed
2008-06-09 07:55 alexy Fixed in Version => 1.71
2013-05-20 21:38 alexy Category MultiArc => MultiArc (old)