MuntashirAkon/AppManager · error · IllegalArgumentException

Major device number is out of range: + devNo

Error message

Major device number is out of range: + devNo

What it means

TarArchiveEntry.setDevMajor(int) stores the major device number used by tar's char/block device entries; tar headers require it to be non-negative. IllegalArgumentException("Major device number is out of range: " + devNo) is thrown for negative values.

Source

Thrown at app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java:934

     * Get this entry's major device number.
     *
     * @return This entry's major device number.
     * @since 1.4
     */
    public int getDevMajor() {
        return devMajor;
    }

    /**
     * Set this entry's major device number.
     *
     * @param devNo This entry's major device number.
     * @throws IllegalArgumentException if the devNo is < 0.
     * @since 1.4
     */
    public void setDevMajor(final int devNo) {
        if (devNo < 0) {
            throw new IllegalArgumentException("Major device number is out of " + "range: " + devNo);
        }
        this.devMajor = devNo;
    }

    /**
     * Get this entry's minor device number.
     *
     * @return This entry's minor device number.
     * @since 1.4
     */
    public int getDevMinor() {
        return devMinor;
    }

    /**
     * Set this entry's minor device number.
     *
     * @param devNo This entry's minor device number.

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Validate devNo >= 0 before calling setDevMajor(); skip or clamp invalid values.
  2. When reading PAX headers, reject negative devmajor values for the entry.
  3. If the value came from an unsigned parse, use Long/unsigned handling and range-check before narrowing to int.
  4. Catch IllegalArgumentException around processPaxHeader and treat the entry as a regular file.

Example fix

// before
entry.setDevMajor(Integer.parseInt(paxValue)); // negative throws
// after
int devMajor = Integer.parseInt(paxValue);
if (devMajor >= 0) {
    entry.setDevMajor(devMajor);
}
Defensive patterns

Strategy: validation

Validate before calling

if (devNo < 0) throw new IllegalArgumentException("devmajor must be >= 0, got " + devNo);
tarEntry.setDevMajor(devNo);

Type guard

boolean isValidDevNumber(int devNo) { return devNo >= 0; }

Try / catch

try { tarEntry.setDevMajor(devNo); } catch (IllegalArgumentException e) { Log.w(TAG, "Ignoring bad devmajor", e); }

Prevention

When it happens

Trigger: Calling setDevMajor() with a negative int, most commonly via processPaxHeader when a PAX header supplies a negative 'devmajor' value, or when populating device-file entries from /dev metadata that was read incorrectly.

Common situations: Archiving device files from a corrupted or synthetic /dev listing; crafted archives with negative PAX devmajor fields; sign issues when the value was parsed as unsigned but stored in int.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/8226ad1aae424f10. Report an issue: GitHub.