dbe32363 fixed an issue of data corruption when deleting files from the
archive by properly creating temporary streams when libzip requested
data modifications. However, a bug crept in which causes the temporary
stream to be rewound, instead of the destination one, when data is
written back. This has the effect of overwriting the ZIP local file
header structure with, essentially, random data and causes errors
similar to:
error XABBA7000: Xamarin.Tools.Zip.ZipException: Zip archive inconsistent: entry 0: invalid WinZip AES extra field
Xamarin.Android.Common.targets(2289,2): error ANDZA0000: zip W 01-25 15:03:13 9516 56652 WARNING: header mismatch
The issue can be seen by either attempting to unpack the archive:
Or by looking at the file with zipinfo -vv base.zip:
Central directory entry #10:
---------------------------
There are an extra 9 bytes preceding this file.
root/assemblies/assemblies.blob
offset of local header from start of archive: 127988 (000000000001F3F4h) bytes
Not only the local header is thought to be at the incorrect offset, it
also doesn't have the correct signature:
Context: dbe3236319eb98116669aa9ed14aaa24bd7ae680
dbe32363 fixed an issue of data corruption when deleting files from the archive by properly creating temporary streams when
libzip
requested data modifications. However, a bug crept in which causes the temporary stream to be rewound, instead of the destination one, when data is written back. This has the effect of overwriting the ZIP local file header structure with, essentially, random data and causes errors similar to:The issue can be seen by either attempting to unpack the archive:
Or by looking at the file with
zipinfo -vv base.zip
:Not only the local header is thought to be at the incorrect offset, it also doesn't have the correct signature:
Attempt to fix the problem by rewinding the destination stream on write.
Fix found by Dean Ellis (@dellis1972)