Menu

#8 MalformedInputException when default charset is not UTF-8

1.0.5
closed
None
2019-01-23
2019-01-23
Gerrit Hohl
No

In the DebianPackageParserImpl class the TarArchiveInputStream is opened without passing an encoding. The results in the stream using the default charset of the JVM, also TAR entries are encoded using UTF-8. This leads to exceptions if the default charset is e.g. US-ASCII.

E.g. when parsing the file ca-certificates_20170717~16.04.2_all.deb the TarArchiveInputStream can't process the entry ./usr/share/ca-certificates/mozilla/TÜRKTRUST_Elektronik_Sertifika_Hizmet_Sağlayıcısı_H5.crt. It will result in the following exception (excerpt of the stack trace):

Caused by: java.io.IOException: Couldn't read entry |data.tar.xz| from AR archive |/tmp/ca-certificates_20170717~16.04.2_all.deb|: Input length = 1
    at net.sourceforge.javadpkg.impl.DebianPackageParserImpl.readData(DebianPackageParserImpl.java:532)
    at net.sourceforge.javadpkg.impl.DebianPackageParserImpl.parseDebianPackage(DebianPackageParserImpl.java:168)
    at net.sourceforge.javadpkg.impl.DebianPackageParserImpl.parseDebianPackage(DebianPackageParserImpl.java:139)
    at de.aurenz.webfox.updater.logic.update.impl.UpdateProcessImpl.parsePackages(UpdateProcessImpl.java:781)
    ... 3 more
Caused by: java.nio.charset.MalformedInputException: Input length = 1
    at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
    at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:816)
    at org.apache.commons.compress.archivers.zip.NioZipEncoding.decode(NioZipEncoding.java:133)
    at org.apache.commons.compress.archivers.tar.TarUtils.parseName(TarUtils.java:298)
    at org.apache.commons.compress.archivers.tar.TarArchiveEntry.parseTarHeader(TarArchiveEntry.java:1246)
    at org.apache.commons.compress.archivers.tar.TarArchiveEntry.parseTarHeader(TarArchiveEntry.java:1237)
    at org.apache.commons.compress.archivers.tar.TarArchiveEntry.<init>(TarArchiveEntry.java:373)
    at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:283)
    at net.sourceforge.javadpkg.impl.DebianPackageParserImpl.readData(DebianPackageParserImpl.java:451)
    ... 6 more

Discussion

  • Gerrit Hohl

    Gerrit Hohl - 2019-01-23
     
  • Gerrit Hohl

    Gerrit Hohl - 2019-01-23

    Fixed in revision #24.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.