Skip to content

Commit

Permalink
Merge branch 'xcode12' into v2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeycode committed Oct 6, 2020
2 parents 2dc9c06 + f0cfbd9 commit 5a4fe35
Show file tree
Hide file tree
Showing 51 changed files with 353 additions and 213 deletions.
24 changes: 24 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contributing to UnrarKit

First of all, if you're reading this, thanks! I love getting feedback from other developers who use this library and welcome any and all feedback. Issues and Pull requests are welcome, with a few guidelines, laid out below.

# Issues

I need the following, at a minimum:

1. The steps to reproduce your issue, detailed enough for me to follow along and see what you're seeing (bonus points for giving me a sample archive that demonstrates the issue)
2. What you expect to happen
3. What actually happened

If what you're reporting is a crash, a crash report is key (or a stack trace, if you don't have a full crash report).

Beyond that, the **quickest way** to get me to address what you're asking for is to provide a unit test (or tests) to demonstrate what you'd like to see (they should probably fail). I have a pretty complete set of tests already in the library that you can use as an example if you'd like.

# Pull Requests

Pull Requests are always greatly appreciated. The general rule of thumb for how quickly something will make it into a future release is the inverse of how much work I'll need to do on it. Creating a PR instead of an issue report takes a huge burden off of me. If you do create a PR, I'll require these things before I merge it:

1. Style needs to mesh with the rest of the repo. I'd love to have some style enforcement checks at some point, but don't yet. Do your best according to what you see in the rest of the source and I'll point out anything you missed. No big deal
2. If you're fixing a bug, I need to see a unit test that reproduces the issue(s) by failing if I comment out your fix. I try to maintain code coverage that's as complete as possible, so more unit tests are always welcome
3. Don't touch the `Libraries/unrar` directory. This is the UnRAR source code, downloaded from [the RARLAB site](https://www.rarlab.com/rar_add.htm), and updated occasionally. You can usually look at the revision history of that folder to see what version it's currently on. This library does cause some compiler warnings, but I ignore them in Xcode and CocoaPods, relying on unit tests to tell me if anything is truly broken, since I don't maintain patches - I expect to be able to drop in newer versions as needed
4. Be patient with the process - I maintain a high attention to detail, and will take however much time is necessary to get the change to where I'd like it. If you'd rather have a more brief back-and-forth, I can always pull into a separate branch to make the changes myself before merging, but enjoy the interaction of collaborating on PRs whenever possible
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Thanks for making a contribution to UnrarKit! I greatly value issue reports, which help make the library better, and more useful to more people. To help me address your issue, please follow the steps below.

_Delete from this line up_

- [ ] Provide a brief, descriptive issue title
- [ ] Fill out the template below
- [ ] **Option A** is the easier, more traditional way of reporting a bug
- [ ] **Option B** gets you bonus points (redeemable in the form of me looking at your issue more quickly). Create a failing unit test that would pass if the issue were resolved. When I go to fix your issue, it's one of the first things I would do anyway. There is a pretty complete set already there, so you can use those as a guide to creating new ones.

## Option A

### Steps to reproduce issue (Detailed enough for me to reproduce - attaching a sample archive can be very helpful):


### What you expect to happen:


### What actually happened:


### (_Optional_) A stack trace or crash report, if you have one:


## Option B

### Brief summary of issue:

### Link to your branch where you've created automated tests to demonstrate the issue (and the name of the unit test(s) you created):
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10.3
osx_image: xcode12

before_script:
# Make log level less verbose. Temporarily undo if more info is needed
Expand All @@ -15,7 +15,7 @@ matrix:
- stage: Test
env: Name=iOS
# The CLANG arguments and find command fail the build on analyzer errors
script: xcodebuild -workspace UnrarKit.xcworkspace -scheme UnrarKit -destination 'platform=iOS Simulator,name=iPhone 7,OS=latest' -configuration Release analyze test CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]
script: xcodebuild -workspace UnrarKit.xcworkspace -scheme UnrarKit -destination 'platform=iOS Simulator,name=iPhone 11,OS=latest' -configuration Release analyze test CLANG_ANALYZER_OUTPUT=html CLANG_ANALYZER_OUTPUT_DIR=analyzer-output && [[ -z `find analyzer-output -name "*.html"` ]]

- stage: Test
env: Name=ExampleAppBuild
Expand Down
6 changes: 3 additions & 3 deletions Classes/URKArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import "UnrarKitMacros.h"
#import <UnrarKit/UnrarKitMacros.h>

RarosHppIgnore
#import "raros.hpp"
#import <UnrarKit/raros.hpp>
#pragma clang diagnostic pop

DllHppIgnore
#import "dll.hpp"
#import <UnrarKit/dll.hpp>
#pragma clang diagnostic pop

@class URKFileInfo;
Expand Down
6 changes: 3 additions & 3 deletions Classes/URKFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
//

#import <Foundation/Foundation.h>
#import "UnrarKitMacros.h"
#import <UnrarKit/UnrarKitMacros.h>

RarosHppIgnore
#import "raros.hpp"
#import <UnrarKit/raros.hpp>
#pragma clang diagnostic pop

DllHppIgnore
#import "dll.hpp"
#import <UnrarKit/dll.hpp>
#pragma clang diagnostic pop

/* See http://www.forensicswiki.org/wiki/RAR and
Expand Down
4 changes: 2 additions & 2 deletions Classes/UnrarKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ FOUNDATION_EXPORT double UnrarKitVersionNumber;
FOUNDATION_EXPORT const unsigned char UnrarKitVersionString[];


#import "URKArchive.h"
#import "URKFileInfo.h"
#import <UnrarKit/URKArchive.h>
#import <UnrarKit/URKFileInfo.h>
18 changes: 8 additions & 10 deletions Example/UnrarExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,15 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1200;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "UnrarExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
en,
Base,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
Expand Down Expand Up @@ -257,6 +255,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -272,14 +271,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = (
"-lc++",
"-all_load",
);
PREBINDING = NO;
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -301,6 +299,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -316,13 +315,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
OTHER_LDFLAGS = (
"-lc++",
"-all_load",
);
PREBINDING = NO;
SDKROOT = iphoneos;
WARNING_CFLAGS = "-Wno-error=unused-command-line-argument";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:UnrarExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
9 changes: 8 additions & 1 deletion Libraries/unrar/arccmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ bool Archive::GetComment(Array<wchar> *CmtData)
{
if (!MainComment)
return false;
SaveFilePos SavePos(*this);
int64 SavePos=Tell();
bool Success=DoGetComment(CmtData);
Seek(SavePos,SEEK_SET);
return Success;
}


bool Archive::DoGetComment(Array<wchar> *CmtData)
{
#ifndef SFX_MODULE
uint CmtLength;
if (Format==RARFMT14)
Expand Down
7 changes: 4 additions & 3 deletions Libraries/unrar/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ bool Archive::IsArchive(bool EnableBroken)
break;
}

// This check allows to make RS based recovery even if password is incorrect.
// But we should not do it for EnableBroken or we'll get 'not RAR archive'

// We should not do it for EnableBroken or we'll get 'not RAR archive'
// messages when extracting encrypted archives with wrong password.
if (FailedHeaderDecryption && !EnableBroken)
return false;
Expand All @@ -233,7 +233,7 @@ bool Archive::IsArchive(bool EnableBroken)
// immediately after IsArchive call.
if (HeadersLeft && (!SilentOpen || !Encrypted))
{
SaveFilePos SavePos(*this);
int64 SavePos=Tell();
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;
HEADER_TYPE SaveCurHeaderType=CurHeaderType;

Expand Down Expand Up @@ -262,6 +262,7 @@ bool Archive::IsArchive(bool EnableBroken)
CurBlockPos=SaveCurBlockPos;
NextBlockPos=SaveNextBlockPos;
CurHeaderType=SaveCurHeaderType;
Seek(SavePos,SEEK_SET);
}
if (!Volume || FirstVolume)
wcsncpyz(FirstVolumeName,FileName,ASIZE(FirstVolumeName));
Expand Down
4 changes: 1 addition & 3 deletions Libraries/unrar/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Archive:public File
void UpdateLatestTime(FileHeader *CurBlock);
void ConvertNameCase(wchar *Name);
void ConvertFileHeader(FileHeader *hd);
void WriteBlock50(HEADER_TYPE HeaderType,BaseBlock *wb,bool OnlySetSize,bool NonFinalWrite);
size_t ReadHeader14();
size_t ReadHeader15();
size_t ReadHeader50();
Expand All @@ -38,6 +37,7 @@ class Archive:public File
void UnexpEndArcMsg();
void BrokenHeaderMsg();
void UnkEncVerMsg(const wchar *Name,const wchar *Info);
bool DoGetComment(Array<wchar> *CmtData);
bool ReadCommentData(Array<wchar> *CmtData);

#if !defined(RAR_NOCRYPT)
Expand Down Expand Up @@ -65,8 +65,6 @@ class Archive:public File
size_t SearchBlock(HEADER_TYPE HeaderType);
size_t SearchSubBlock(const wchar *Type);
size_t SearchRR();
void WriteBlock(HEADER_TYPE HeaderType,BaseBlock *wb=NULL,bool OnlySetSize=false,bool NonFinalWrite=false);
void SetBlockSize(HEADER_TYPE HeaderType,BaseBlock *wb=NULL) {WriteBlock(HeaderType,wb,true);}
size_t ReadHeader();
void CheckArc(bool EnableBroken);
void CheckOpen(const wchar *Name);
Expand Down
12 changes: 7 additions & 5 deletions Libraries/unrar/arcread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ size_t Archive::ReadHeader15()
{
// Last 7 bytes of recovered volume can contain zeroes, because
// REV files store its own information (volume number, etc.) here.
SaveFilePos SavePos(*this);
int64 Length=Tell();
Seek(Length-7,SEEK_SET);
Recovered=true;
Expand Down Expand Up @@ -584,7 +583,7 @@ size_t Archive::ReadHeader50()
{
// This message is used by Android GUI to reset cached passwords.
// Update appropriate code if changed.
uiMsg(UIERROR_BADPSW,FileName);
uiMsg(UIERROR_BADPSW,FileName,FileName);
FailedHeaderDecryption=true;
ErrHandler.SetErrorCode(RARX_BADPWD);
return 0;
Expand All @@ -593,7 +592,7 @@ size_t Archive::ReadHeader50()
{
// This message is used by Android GUI and Windows GUI and SFX to
// reset cached passwords. Update appropriate code if changed.
uiMsg(UIWAIT_BADPSW,FileName);
uiMsg(UIWAIT_BADPSW,FileName,FileName);
Cmd->Password.Clean();
}

Expand Down Expand Up @@ -720,6 +719,7 @@ size_t Archive::ReadHeader50()
UnkEncVerMsg(FileName,Info);
return 0;
}

Raw.GetB(CryptHead.Salt,SIZE_SALT50);
if (CryptHead.UsePswCheck)
{
Expand Down Expand Up @@ -1256,11 +1256,13 @@ size_t Archive::ReadHeader14()
Raw.Read(NameSize);

char FileName[NM];
Raw.GetB((byte *)FileName,Min(NameSize,ASIZE(FileName)));
FileName[NameSize]=0;
size_t ReadNameSize=Min(NameSize,ASIZE(FileName)-1);
Raw.GetB((byte *)FileName,ReadNameSize);
FileName[ReadNameSize]=0;
IntToExt(FileName,FileName,ASIZE(FileName));
CharToWide(FileName,FileHead.FileName,ASIZE(FileHead.FileName));
ConvertNameCase(FileHead.FileName);
ConvertFileHeader(&FileHead);

if (Raw.Size()!=0)
NextBlockPos=CurBlockPos+FileHead.HeadSize+FileHead.PackSize;
Expand Down
1 change: 0 additions & 1 deletion Libraries/unrar/cmddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,6 @@ void CommandData::ProcessCommand()
case 'X':
case 'E':
case 'T':
case 'I':
{
CmdExtract Extract(this);
Extract.DoExtract();
Expand Down
2 changes: 1 addition & 1 deletion Libraries/unrar/crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size)
crc_tables[5][(byte)(StartCRC >> 16)] ^
crc_tables[4][(byte)(StartCRC >> 24)] ^
crc_tables[3][(byte) NextData ] ^
crc_tables[2][(byte)(NextData >>8 ) ] ^
crc_tables[2][(byte)(NextData >> 8) ] ^
crc_tables[1][(byte)(NextData >> 16)] ^
crc_tables[0][(byte)(NextData >> 24)];
}
Expand Down
18 changes: 9 additions & 9 deletions Libraries/unrar/dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
r->Flags=0;

if (Data->Arc.Volume)
r->Flags|=0x01;
r->Flags|=ROADF_VOLUME;
if (Data->Arc.MainComment)
r->Flags|=0x02;
r->Flags|=ROADF_COMMENT;
if (Data->Arc.Locked)
r->Flags|=0x04;
r->Flags|=ROADF_LOCK;
if (Data->Arc.Solid)
r->Flags|=0x08;
r->Flags|=ROADF_SOLID;
if (Data->Arc.NewNumbering)
r->Flags|=0x10;
r->Flags|=ROADF_NEWNUMBERING;
if (Data->Arc.Signed)
r->Flags|=0x20;
r->Flags|=ROADF_SIGNED;
if (Data->Arc.Protected)
r->Flags|=0x40;
r->Flags|=ROADF_RECOVERY;
if (Data->Arc.Encrypted)
r->Flags|=0x80;
r->Flags|=ROADF_ENCHEADERS;
if (Data->Arc.FirstVolume)
r->Flags|=0x100;
r->Flags|=ROADF_FIRSTVOLUME;

Array<wchar> CmtDataW;
if (r->CmtBufSize!=0 && Data->Arc.GetComment(&CmtDataW))
Expand Down
Loading

0 comments on commit 5a4fe35

Please sign in to comment.