Skip to content

Commit b332af0

Browse files
authored
Fix Native Crash on Windows. (#67)
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.
1 parent 96eb5e3 commit b332af0

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

LibZipSharp.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<_LibZipSharpNugetVersion>1.0.16</_LibZipSharpNugetVersion>
3+
<_LibZipSharpNugetVersion>1.0.17</_LibZipSharpNugetVersion>
44
</PropertyGroup>
55
</Project>

azure-pipelines.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ stages:
2424
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
2525
git submodule update --init --recursive
2626
displayName: 'Install Tools'
27-
# - bash: |
28-
# patch --verbose -d external/libzip -p1 -l < libzip-static.patch
29-
# displayName: 'Apply Patch'
27+
- bash: |
28+
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
29+
displayName: 'Apply Patch'
3030
- bash: |
3131
./build_native
3232
displayName: 'Build Linux x64'
@@ -37,16 +37,16 @@ stages:
3737
- task: ArchiveFiles@2
3838
inputs:
3939
rootFolderOrFile: build/Linux/32/lib/libzip.so.5.3
40-
includeRootFolder: false
40+
includeRootFolder: false
4141
archiveType: 7z
42-
replaceExistingArchive: true
42+
replaceExistingArchive: true
4343
archiveFile: $(Build.ArtifactStagingDirectory)/libzip-linux-x86.7z
4444
- task: ArchiveFiles@2
4545
inputs:
4646
rootFolderOrFile: build/Linux/64/lib/libzip.so.5.3
47-
includeRootFolder: false
47+
includeRootFolder: false
4848
archiveType: 7z
49-
replaceExistingArchive: true
49+
replaceExistingArchive: true
5050
archiveFile: $(Build.ArtifactStagingDirectory)/libzip-linux-x64.7z
5151
- task: PublishBuildArtifacts@1
5252
displayName: upload artifacts
@@ -65,6 +65,9 @@ stages:
6565
brew install ninja xamarin/xamarin-android-windeps/mingw-zlib
6666
git submodule update --init --recursive
6767
displayName: 'Install toolchain'
68+
- bash: |
69+
patch --verbose -d external/libzip -p1 -l < libzip-changes.patch
70+
displayName: 'Apply Patch'
6871
- bash: |
6972
HOSTOS=Darwin ./build_native
7073
./build_windows
@@ -97,7 +100,7 @@ stages:
97100
inputs:
98101
solution: libZipSharp.csproj
99102
configuration: Release
100-
msbuildArguments: /restore /v:diag
103+
msbuildArguments: /restore /v:diag
101104
- task: MSBuild@1
102105
displayName: NuGet pack libZipSharp
103106
inputs:

libzip-changes.patch

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/lib/zip_stat_index.c b/lib/zip_stat_index.c
2+
index 0f8bead8..62dc0455 100644
3+
--- a/lib/zip_stat_index.c
4+
+++ b/lib/zip_stat_index.c
5+
@@ -55,7 +55,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
6+
return -1;
7+
}
8+
9+
- if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
10+
+ if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
11+
st->mtime = de->last_mod;
12+
st->valid |= ZIP_STAT_MTIME;
13+
}

0 commit comments

Comments
 (0)