MuntashirAkon/AppManager · error · IllegalArgumentException

${exceptionMessage(buffer, offset, length, start, currentByt

Error message

${exceptionMessage(buffer, offset, length, start, currentByte)}

What it means

TarUtils.parseOctal throws this IllegalArgumentException when it encounters a byte that is not an ASCII octal digit ('0'-'7') inside the numeric field. exceptionMessage() builds a human-readable string showing the offending byte and position. This means the tar header field is not valid octal — typically because the archive uses GNU base-256 binary encoding, or the header is corrupt.

Source

Thrown at app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java:136

                break;
            }
        }

        // Trim all trailing NULs and spaces.
        // The ustar and POSIX tar specs require a trailing NUL or
        // space but some implementations use the extra digit for big
        // sizes/uids/gids ...
        byte trailer = buffer[end - 1];
        while (start < end && (trailer == 0 || trailer == ' ')) {
            end--;
            trailer = buffer[end - 1];
        }

        for ( ;start < end; start++) {
            final byte currentByte = buffer[start];
            // CheckStyle:MagicNumber OFF
            if (currentByte < '0' || currentByte > '7'){
                throw new IllegalArgumentException(
                        exceptionMessage(buffer, offset, length, start, currentByte));
            }
            result = (result << 3) + (currentByte - '0'); // convert from ASCII
            // CheckStyle:MagicNumber ON
        }

        return result;
    }

    /**
     * Compute the value contained in a byte buffer.  If the most
     * significant bit of the first byte in the buffer is set, this
     * bit is ignored and the rest of the buffer is interpreted as a
     * binary number.  Otherwise, the buffer is interpreted as an
     * octal number as per the parseOctal function above.
     *
     * @param buffer The buffer from which to parse.
     * @param offset The offset into the buffer from which to parse.

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Call TarUtils.parseOctalOrBinary(buffer, offset, length) instead of parseOctal — it handles both octal and base-256 binary fields
  2. Re-download/re-extract the archive if the source is corrupted (verify with tar -tf or checksums first)
  3. If you must keep parseOctal, pre-check for the base-256 marker byte (buffer[offset] & 0x80) != 0 and route to binary parsing
  4. Check the field offset/length against the tar spec in case you are parsing the wrong bytes

Example fix

// before
long size = TarUtils.parseOctal(header, offset, TarConstants.SIZELEN);
// after
long size = TarUtils.parseOctalOrBinary(header, offset, TarConstants.SIZELEN);
Defensive patterns

Strategy: validation

Validate before calling

public static long safeParseNumeric(byte[] buffer, int offset, int length) {
    if (length >= 1 && (buffer[offset] & 0x80) != 0) {
        return TarUtils.parseOctalOrBinary(buffer, offset, length); // base-256 GNU field
    }
    return TarUtils.parseOctal(buffer, offset, length);
}

Type guard

static boolean isBase256Field(byte[] buffer, int offset) {
    return offset < buffer.length && (buffer[offset] & 0x80) != 0;
}

Try / catch

try {
    long size = TarUtils.parseOctal(header, offset, TarConstants.SIZELEN);
} catch (IllegalArgumentException e) {
    // invalid digit — probably GNU base-256 or corrupt data
    size = TarUtils.parseOctalOrBinary(header, offset, TarConstants.SIZELEN);
}

Prevention

When it happens

Trigger: Parsing a tar created with GNU base-256 encoding (values >= 8GB, or negative sizes) using plain parseOctal instead of parseOctalOrBinary; corrupted archives with garbage in size/mtime/checksum fields.

Common situations: Reading GNU tar archives with very large files through code that assumes pure octal headers; manually implemented tar parsers; truncated or bit-rotted archive files.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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