Improve the handling of invalid UTF-8 byte sequences for ZipInputStream::getNextEntry and ZipFile::getComment

XMLWordPrintable

    • behavioral
    • minimal
    • Hide
      Low risk change: ZIP file comments are rarely used, and no prior reports exist of ZipFile::getComment throwing exceptions in
      production.
      Show
      Low risk change: ZIP file comments are rarely used, and no prior reports exist of ZipFile::getComment throwing exceptions in production.
    • Other
    • JDK

      Summary

      An IllegalArgumentException may be thrown by ZipFile::getComment if there is a problem decoding the bytes representing the Zip file comment.

      Problem

      ZipFile::getComment may throw an IllegalArgumentException if an error occurs when decoding the bytes which represent the Zip file comment. Unfortunately the specification for ZipFile::getComment does not specify that this method may throw an Exception.

      Solution

      In the event of an exception when decoding the byte array that represents the Zip file comment, ZipFile::getComment will now return null instead of a spurious IllegalArgumentException.

      Specification

      There is no specification change in this backport CSR. The API specification of ZipFile::getComment() will not be changed. Only the implementation behavior will be changed such that ZipFile::getComment() will return null instead of throwing an IllegalArgumentException in the case of a corrupted UTF-8 byte stream.

            Assignee:
            Roland Mesde
            Reporter:
            Webbug Group
            Volker Simonis
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: