MuntashirAkon/AppManager · error · IllegalArgumentException
Size is out of range: + size
Error message
Size is out of range: + size
What it means
TarArchiveEntry.setSize(long) validates that a tar entry's size is non-negative before storing it; tar headers cannot represent negative sizes. IllegalArgumentException("Size is out of range: " + size) is thrown for negative values.
Source
Thrown at app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java:910
/**
* Get if this entry is a sparse file with 1.X PAX Format or not
*
* @return True if this entry is a sparse file with 1.X PAX Format
* @since 1.20
*/
public boolean isPaxGNU1XSparse() {
return paxGNU1XSparse;
}
/**
* Set this entry's file size.
*
* @param size This entry's new file size.
* @throws IllegalArgumentException if the size is < 0.
*/
public void setSize(final long size) {
if (size < 0) {
throw new IllegalArgumentException("Size is out of range: " + size);
}
this.size = size;
}
/**
* 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.View on GitHub (pinned to 0152f468fc)
Solutions
- Clamp or validate the size to >= 0 before calling setSize().
- Fix the size computation (e.g. Math.max(0, end - start)) or use Files.size(path) for the true length.
- When reading, reject archives whose PAX size header is negative rather than propagating it.
- Catch IllegalArgumentException and skip the offending entry with a log.
Example fix
// before entry.setSize(file.length() - skipped); // may go negative // after long size = Math.max(0, file.length() - skipped); entry.setSize(size);
Defensive patterns
Strategy: validation
Validate before calling
if (size < 0) throw new IllegalArgumentException("Entry size must be >= 0, got " + size);
tarEntry.setSize(size); Type guard
boolean isValidTarSize(long size) { return size >= 0 && size <= 0x7FFFFFFFFFFFFFFFL; } Try / catch
try { tarEntry.setSize(size); } catch (IllegalArgumentException e) { Log.w(TAG, "Skipping entry with bad size", e); } Prevention
- Compute sizes with Math.max(0, ...)
- Use Files.size() instead of manual offset math
- Sanitize PAX size headers when reading untrusted archives
When it happens
Trigger: Calling setSize() with a negative long — typically from a corrupted/overflowed length value, a size computed as (end - start) where start > end, or a PaxHeader ('size=' via processPaxHeader) carrying a negative number.
Common situations: Backing up files whose reported length underflowed; computing entry size from wrong offsets; malicious/corrupted PAX headers in a crafted archive; long overflow when summing chunk sizes.
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
- APK files backup is requested but no APK files have been bac
- APK files backup is requested but no APK files have been bac
- Major device number is out of range: + devNo
- Request to write '${numToWrite}' bytes exceeds size in heade
- Record to write has length '${record.length}' which is not t
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/79d531a01b3c7532.
Report an issue: GitHub.