{"record":{"id":"8226ad1aae424f10","repo":"MuntashirAkon/AppManager","slug":"major-device-number-is-out-of-range-devno","errorCode":null,"errorMessage":"Major device number is out of range: + devNo","messagePattern":"Major device number is out of range: \\+ devNo","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java","lineNumber":934,"sourceCode":"     * Get this entry's major device number.\n     *\n     * @return This entry's major device number.\n     * @since 1.4\n     */\n    public int getDevMajor() {\n        return devMajor;\n    }\n\n    /**\n     * Set this entry's major device number.\n     *\n     * @param devNo This entry's major device number.\n     * @throws IllegalArgumentException if the devNo is &lt; 0.\n     * @since 1.4\n     */\n    public void setDevMajor(final int devNo) {\n        if (devNo < 0) {\n            throw new IllegalArgumentException(\"Major device number is out of \" + \"range: \" + devNo);\n        }\n        this.devMajor = devNo;\n    }\n\n    /**\n     * Get this entry's minor device number.\n     *\n     * @return This entry's minor device number.\n     * @since 1.4\n     */\n    public int getDevMinor() {\n        return devMinor;\n    }\n\n    /**\n     * Set this entry's minor device number.\n     *\n     * @param devNo This entry's minor device number.","sourceCodeStart":916,"sourceCodeEnd":952,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java#L916-L952","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Validate devNo >= 0 before calling setDevMajor(); skip or clamp invalid values.","When reading PAX headers, reject negative devmajor values for the entry.","If the value came from an unsigned parse, use Long/unsigned handling and range-check before narrowing to int.","Catch IllegalArgumentException around processPaxHeader and treat the entry as a regular file."],"exampleFix":"// before\nentry.setDevMajor(Integer.parseInt(paxValue)); // negative throws\n// after\nint devMajor = Integer.parseInt(paxValue);\nif (devMajor >= 0) {\n    entry.setDevMajor(devMajor);\n}","handlingStrategy":"validation","validationCode":"if (devNo < 0) throw new IllegalArgumentException(\"devmajor must be >= 0, got \" + devNo);\ntarEntry.setDevMajor(devNo);","typeGuard":"boolean isValidDevNumber(int devNo) { return devNo >= 0; }","tryCatchPattern":"try { tarEntry.setDevMajor(devNo); } catch (IllegalArgumentException e) { Log.w(TAG, \"Ignoring bad devmajor\", e); }","preventionTips":["Range-check values parsed from PAX headers","Handle unsigned parse results before narrowing to int","Treat device entries from untrusted archives as regular files"],"tags":["tar","archive","device-number"],"backgroundTag":"value-out-of-range","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}