Skip to content

Commit

Permalink
Fix Native Crash on Windows. (#67)
Browse files Browse the repository at this point in the history
We had a problem in Xamarin.Android where libzip
would crash on our test machine. This turned out
to be a bung in libzip itself.

	nih-at/libzip#202

There was a missing `NULL` check in `zip_stat_index`.
This PR adds a patch to allow us to patch this problem
in the latest release of `libzip` so that we can
bump to the latest version in Xamrain.Android.
  • Loading branch information
dellis1972 authored Aug 5, 2020
1 parent 96eb5e3 commit b332af0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion LibZipSharp.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LibZipSharpNugetVersion>1.0.16</_LibZipSharpNugetVersion>
<_LibZipSharpNugetVersion>1.0.17</_LibZipSharpNugetVersion>
</PropertyGroup>
</Project>
19 changes: 11 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ stages:
sudo apt -f -u install ninja-build gcc-multilib lib32z1-dev zlib1g-dev libssl-dev libssl1.1:i386 libssl-dev:i386 libc-dev:i386 libc6-dev-i386 -y
git submodule update --init --recursive
displayName: 'Install Tools'
# - bash: |
# patch --verbose -d external/libzip -p1 -l < libzip-static.patch
# displayName: 'Apply Patch'
- bash: |
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
displayName: 'Apply Patch'
- bash: |
./build_native
displayName: 'Build Linux x64'
Expand All @@ -37,16 +37,16 @@ stages:
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: build/Linux/32/lib/libzip.so.5.3
includeRootFolder: false
includeRootFolder: false
archiveType: 7z
replaceExistingArchive: true
replaceExistingArchive: true
archiveFile: $(Build.ArtifactStagingDirectory)/libzip-linux-x86.7z
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: build/Linux/64/lib/libzip.so.5.3
includeRootFolder: false
includeRootFolder: false
archiveType: 7z
replaceExistingArchive: true
replaceExistingArchive: true
archiveFile: $(Build.ArtifactStagingDirectory)/libzip-linux-x64.7z
- task: PublishBuildArtifacts@1
displayName: upload artifacts
Expand All @@ -65,6 +65,9 @@ stages:
brew install ninja xamarin/xamarin-android-windeps/mingw-zlib
git submodule update --init --recursive
displayName: 'Install toolchain'
- bash: |
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
displayName: 'Apply Patch'
- bash: |
HOSTOS=Darwin ./build_native
./build_windows
Expand Down Expand Up @@ -97,7 +100,7 @@ stages:
inputs:
solution: libZipSharp.csproj
configuration: Release
msbuildArguments: /restore /v:diag
msbuildArguments: /restore /v:diag
- task: MSBuild@1
displayName: NuGet pack libZipSharp
inputs:
Expand Down
13 changes: 13 additions & 0 deletions libzip-changes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/zip_stat_index.c b/lib/zip_stat_index.c
index 0f8bead8..62dc0455 100644
--- a/lib/zip_stat_index.c
+++ b/lib/zip_stat_index.c
@@ -55,7 +55,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
return -1;
}

- if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
+ if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
st->mtime = de->last_mod;
st->valid |= ZIP_STAT_MTIME;
}

0 comments on commit b332af0

Please sign in to comment.