Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-642

Integer overflow ArithmeticException in TarArchiveOutputStream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.22
    • 1.23.0
    • Compressors
    • None

    Description

      Writing large entries (>1.1 TB) end with an integer overflow

      Caused by: java.lang.ArithmeticException: integer overflow
      	at java.base/java.lang.Math.addExact(Math.java:883)
      	at org.apache.commons.compress.utils.ExactMath.add(ExactMath.java:43)
      	at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.closeArchiveEntry(TarArchiveOutputStream.java:439)
      

      The problem occurs due to the following add exact that was introduced in 1.22 that detects overflows(harmless in this case since the value is only used in modulo checks):

      recordsWritten = ExactMath.add(recordsWritten, (currSize / RECORD_SIZE));
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              klaren Anton Klarén
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: