{"record":{"id":"a1bd9b199fc8f4d7","repo":"MuntashirAkon/AppManager","slug":"failed-to-read-paxheader-encountered-a-non-number-while","errorCode":null,"errorMessage":"Failed to read Paxheader. Encountered a non-number while reading length","messagePattern":"Failed to read Paxheader\\. Encountered a non-number while reading length","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java","lineNumber":760,"sourceCode":"                                if (keyword.equals(\"GNU.sparse.numbytes\")) {\n                                    if (offset == null) {\n                                        throw new IOException(\"Failed to read Paxheader.\" +\n                                                \"GNU.sparse.offset is expected before GNU.sparse.numbytes shows up.\");\n                                    }\n                                    sparseHeaders.add(new TarArchiveStructSparse(offset, Long.parseLong(value)));\n                                    offset = null;\n                                }\n                            }\n                            break;\n                        }\n                        coll.write((byte) ch);\n                    }\n                    break; // Processed single header\n                }\n\n                // COMPRESS-530 : throw if we encounter a non-number while reading length\n                if (ch < '0' || ch > '9') {\n                    throw new IOException(\"Failed to read Paxheader. Encountered a non-number while reading length\");\n                }\n\n                len *= 10;\n                len += ch - '0';\n            }\n            if (ch == -1){ // EOF\n                break;\n            }\n        }\n        if (offset != null) {\n            // offset but no numBytes\n            sparseHeaders.add(new TarArchiveStructSparse(offset, 0));\n        }\n        return headers;\n    }\n\n    /**\n     * For PAX Format 0.1, the sparse headers are stored in a single variable : GNU.sparse.map","sourceCodeStart":742,"sourceCodeEnd":778,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java#L742-L778","documentation":"Thrown by TarUtils.parsePaxHeaders while parsing the decimal length prefix of a PAX record when a byte that is not an ASCII digit is found (COMPRESS-530 fix). The PAX format requires records to start with a decimal byte count; anything else is malformed input, previously causing silent bad parses.","triggerScenarios":"Reading a stream positioned at data that is not a valid PAX record length: corrupt archive, wrong stream offset, or a non-PAX header misinterpreted as PAX data.","commonSituations":"Mixing archive formats (reading a ustar/oldgnu header as pax), corruption from FTP ASCII-mode transfers, or fuzzed files.","solutions":["Verify the archive is valid and not corrupted (checksum, tar -tvf test)","Ensure the stream is positioned at the actual PAX header record, not elsewhere","Re-transfer in binary mode if the file passed through text-mode transfer (line-ending mangling)","Catch IOException and reject the archive"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity-check the file starts like a tar before parsing\nbyte[] h = new byte[512];\nif (!Magic.isTarHeader(h)) throw new IOException(\"Not a valid tar archive\");","typeGuard":null,"tryCatchPattern":"try {\n    // read tar\n} catch (IOException e) {\n    if (e.getMessage().contains(\"non-number while reading length\")) {\n        throw new CorruptArchiveException(\"PAX record length prefix is not numeric\", e);\n    }\n    throw e;\n}","preventionTips":["Transfer archives in binary mode only (no ASCII/FTP text mode)","Validate the archive externally (tar -tvf) before parsing","Don't seek/reposition the stream to arbitrary offsets before parsePaxHeaders"],"tags":["tar","pax-header","parse-error","malformed-data"],"backgroundTag":"invalid-argument-format","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}