{"record":{"id":"19c65a197e5e06fb","repo":"MuntashirAkon/AppManager","slug":"error-detected-parsing-the-pax-header","errorCode":null,"errorMessage":"Error detected parsing the pax header","messagePattern":"Error detected parsing the pax header","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java","lineNumber":413,"sourceCode":"            final String name = zipEncoding.decode(longNameData);\n            currEntry.setName(name);\n            if (currEntry.isDirectory() && !name.endsWith(\"/\")) {\n                currEntry.setName(name + \"/\");\n            }\n        }\n\n        if (currEntry.isGlobalPaxHeader()){ // Process Global Pax headers\n            readGlobalPaxHeaders();\n        }\n\n        try {\n            if (currEntry.isPaxHeader()){ // Process Pax headers\n                paxHeaders();\n            } else if (!globalPaxHeaders.isEmpty()) {\n                applyPaxHeadersToCurrentEntry(globalPaxHeaders, globalSparseHeaders);\n            }\n        } catch (final NumberFormatException e) {\n            throw new IOException(\"Error detected parsing the pax header\", e);\n        }\n\n        if (currEntry.isOldGNUSparse()){ // Process sparse files\n            readOldGNUSparse();\n        }\n\n        // If the size of the next element in the archive has changed\n        // due to a new size being reported in the posix header\n        // information, we update entrySize here so that it contains\n        // the correct value.\n        entrySize = currEntry.getSize();\n\n        return currEntry;\n    }\n\n    /**\n     * The last record block should be written at the full size, so skip any\n     * additional space used to fill a record after an entry.","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java#L395-L431","documentation":"Wraps a NumberFormatException raised while processing PAX extended header entries in getNextTarEntry. A PAX header record's numeric value (e.g. size, devmajor/devminor, or a GNU sparse field) was not a valid number, so the stream fails with an IOException identifying the PAX header as the culprit.","triggerScenarios":"getNextTarEntry() (via getNextEntry()) encounters an entry flagged as a PAX header whose key=value records contain non-numeric values where numbers are required (bad 'size', 'GNU.sparse.*' fields).","commonSituations":"Archives edited or truncated by text-based tools (PAX headers are plain text, so editors can mangle them); archives from non-compliant tar implementations.","solutions":["Re-create the archive with a compliant tool (GNU tar with --format=pax or --format=gnu)","Check that the archive wasn't modified after creation (compare hashes)","Avoid text-editing/normalizing archive files in transit","Catch IOException around getNextTarEntry and surface a corrupt-archive message"],"exampleFix":"// before\nwhile ((entry = tarIn.getNextTarEntry()) != null) { ... }\n// after\ntry {\n    while ((entry = tarIn.getNextTarEntry()) != null) { ... }\n} catch (IOException e) {\n    throw new IOException(\"Failed reading PAX header entry\", e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    TarArchiveEntry e = tarIn.getNextTarEntry();\n} catch (IOException e) {\n    if (e.getCause() instanceof NumberFormatException) {\n        throw new IOException(\"Malformed PAX header in archive\", e);\n    }\n    throw e;\n}","preventionTips":["Create archives with --format=pax using GNU tar or bsdtar","Never modify archive files with text tools","Reject archives whose hash doesn't match the source"],"tags":["tar","pax-header","corrupt-archive"],"backgroundTag":"corrupt-archive-header","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"}