[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-07-01 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16529056#comment-16529056
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

At least apk-golf will provide me with ideas how to create such an APK, which 
probably means I first need to install an Android SDK. I'll leave that for 
another day :)

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-07-01 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16529054#comment-16529054
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

The current master branch can now read both APKs, but the code lacks all tests 
and contains two branches I haven't even run, yet. I'll need to find a way to 
write tests before I can close this issue.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-07-01 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16529044#comment-16529044
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

I think what you see is the APK signing block 
[https://source.android.com/security/apksigning/v2] which sits between all 
local file headers and the central directory. Commons Compress doesn't know how 
to parse the block or just to detect it and skip over it.

Unfortunately the block does not start with a signature (but rather ends with 
it) so it is difficult to know whether what we see is such a block. The block 
starts with eight bytes holding the length, so we could try to interpret the 
next eight bytes as a length, skip over a block of that size, see whether we 
find the "APK Sig Block 42” and call it a day.

In order to have a testcase we probably need a very small apk that is signed 
and can be distributed as part of our source tree.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-06-16 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16514777#comment-16514777
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

java.util.zip has other problems which made us - actually ant-dev - implement a 
replacement in the first place. If it works for use case, then things are fine 
:)

Thank you for the explanation, this probably means you cant't use 7z in Oreo at 
all as it also relies on nio.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-06-15 Thread Hai Zhang (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16514601#comment-16514601
 ] 

Hai Zhang commented on COMPRESS-455:


Thanks for the answer! I didn't realize the central directory is actually at 
the end of a zip file.

Regarding Android, ZipFile is not usable before Android Oreo because the nio 
file package is [not available before it (you can see "
added in API level 
26")|https://developer.android.com/reference/java/nio/file/Files#newByteChannel(java.nio.file.Path,%20java.nio.file.OpenOption...)],
 so that calling {{Files.newByteChannel()}} results in an exception. The 
{{java.util.zip.ZipFile}} on Android don't have such problem because it is 
[using some native calls and mmap for 
this|https://android.googlesource.com/platform/libcore/+/master/ojluni/src/main/java/java/util/zip/ZipFile.java],
 so that I'm falling back to it before Oreo.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-06-15 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16514171#comment-16514171
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

Unfortunately this really requires random access which is not possible with a 
stream based API (unless you capture the whole stream to a file or in memory, 
that is). The "central directory" of a ZIP archive is at the end of the archive 
while all entry content is before it. {{ZipFile}} has several advantages over 
{{ZipArchiveInputStream}} - see 
https://commons.apache.org/proper/commons-compress/zip.html#ZipArchiveInputStream_vs_ZipFile
 - so I can only recommend to special case the ZIP format as you have to do for 
7z as well.

I'm not familiar enough with Android but curious. Why can you use Commons 
Compress' {{ZipArchiveInputStream}} but not {{ZipFile}} on Oreo - they should 
require the same Java VM version.

Please don't close this issue as I intend to look into the archives you've 
linked in order to see whether they are really broken or there is anything we 
can do to make {{ZipArchiveInputStream}} handle them.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-06-13 Thread Hai Zhang (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16510779#comment-16510779
 ] 

Hai Zhang commented on COMPRESS-455:


Thanks for the answer; using {{ZipFile}} did work well for those files (except 
that I need to fallback to {{java.util.zip.ZipFile}} on versions before Android 
Oreo). I wonder if {{ZipArchiveInputStream}} can also read the central 
directory so that such most files (except 7z which don't support the stream) 
can be read in a uniform way?

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (COMPRESS-455) Cannot open certain APK file (Unexpected record signature)

2018-06-12 Thread Stefan Bodewig (JIRA)


[ 
https://issues.apache.org/jira/browse/COMPRESS-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16509784#comment-16509784
 ] 

Stefan Bodewig commented on COMPRESS-455:
-

The signature consisting of only two bytes looks strange (I'd expect the usual 
"PK" bytes if this simply was some kind of unsupported feature inside of a 
regular archive. Have you tried using {{ZipFile}} rather than 
{{ZipArchiveInputStream}}? This has the benefit of being able to read the 
central directory and doesn't have to scan the archive sequentially performing 
pattern matching on suspect header signatures.

> Cannot open certain APK file (Unexpected record signature)
> --
>
> Key: COMPRESS-455
> URL: https://issues.apache.org/jira/browse/COMPRESS-455
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.17
> Environment: Android 8.1.0
>Reporter: Hai Zhang
>Priority: Major
>
> I'm developing a file manager for Android and noticed that 
> ZipArchiveInputStream throws an exception for certain APK files (but not all) 
> I have at hand:
>  
> {noformat}
> 06-12 23:01:03.043 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: java.util.zip.ZipException: Unexpected record signature: 0X621
> 06-12 23:01:03.044 26960-4050/me.zhanghai.android.materialfilemanager 
> W/System.err: at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:258)
>  at 
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextEntry(ZipArchiveInputStream.java:406)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.readEntries(Archive.java:79)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.Archive.read(Archive.java:36)
>  at 
> me.zhanghai.android.materialfilemanager.filesystem.ArchiveFile.loadFileList(ArchiveFile.java:112)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:32)
>  at 
> me.zhanghai.android.materialfilemanager.filelist.FileLiveData$1.doInBackground(FileLiveData.java:28)
>  at android.os.AsyncTask$2.call(AsyncTask.java:333)
>  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
>  at java.lang.Thread.run(Thread.java:764){noformat}
>  
> However, these APKs installs fine, and can be viewed by the system Files app 
> (by changing extension to zip) and some other opensource file managers built 
> upon java.util.zip.
> Some links to APKs I found with this problem:
> 1. 
> [https://github.com/paphonb/PixelLauncherModV5/releases/download/5.3_23/Pixel.2.Launcher.modded.5.3.build.23.apk]
>  
> 2. 
> [https://github.com/Yink/Amadeus/releases/download/0.9.6-alpha.5/amadeus.apk]
> My code for reading the APK archive entries:
>  
>  
> {code:java}
> private static void readEntries(InputStream inputStream, List 
> entries)
> throws ArchiveException, IOException {
> try (ArchiveInputStream archiveInputStream = 
> sArchiveStreamFactory.createArchiveInputStream(
> new BufferedInputStream(inputStream))) {
> while (true) {
> ArchiveEntry entry = archiveInputStream.getNextEntry();
> if (entry == null) {
> break;
> }
> entries.add(entry);
> }
> }
> }
> {code}
> Also note that if I catch the exception while keeping the list of 
> already-read entries, it seems that (almost) all entries have been read.
> I wonder how this can be fixed, or if this is because those files have some 
> kind of weird format, how can I possibly work around this?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)