{"record":{"id":"babd8c3b09d0b999","repo":"peass-ng/PEASS-ng","slug":"eof-found-when-length-expected","errorCode":null,"errorMessage":"EOF found when length expected","messagePattern":"EOF found when length expected","errorType":"exception","errorClass":"EndOfStreamException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs","lineNumber":277,"sourceCode":"                    tagNo |= (b & 0x7f);\n                    tagNo <<= 7;\n                    b = s.ReadByte();\n                }\n\n                if (b < 0)\n                    throw new EndOfStreamException(\"EOF found inside tag value.\");\n\n                tagNo |= (b & 0x7f);\n            }\n\n            return tagNo;\n        }\n\n        internal static int ReadLength(Stream s, int limit, bool isParsing)\n        {\n            int length = s.ReadByte();\n            if (length < 0)\n                throw new EndOfStreamException(\"EOF found when length expected\");\n\n            if (length == 0x80)\n                return -1;      // indefinite-length encoding\n\n            if (length > 127)\n            {\n                int size = length & 0x7f;\n\n                // Note: The invalid long form \"0xff\" (see X.690 8.1.3.5c) will be caught here\n                if (size > 4)\n                    throw new IOException(\"DER length more than 4 bytes: \" + size);\n\n                length = 0;\n                for (int i = 0; i < size; i++)\n                {\n                    int next = s.ReadByte();\n\n                    if (next < 0)","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs#L259-L295","documentation":"An EndOfStreamException from ReadLength: the first byte read for the length octets of a TLV was -1, i.e. the stream ended right after the tag with no length field present. It indicates a truncated or prematurely terminated ASN.1 stream.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/asn1/Asn1InputStream.cs:277 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the input is complete and well-formed ASN.1 before constructing Asn1InputStream","Fix upstream truncation (network cutoff, partial file write, bad Base64 decode)","Catch EndOfStreamException where partial/malformed input is expected and report it as malformed data"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}