{"record":{"id":"7a6ab5eea2618fbc","repo":"apache/cassandra","slug":"buffer-to-uncompress-into-is-not-large-enough-buf","errorCode":null,"errorMessage":"buffer to uncompress into is not large enough; buf size = %d, buf offset = %d, target size = %s","messagePattern":"buffer to uncompress into is not large enough; buf size = (.+?), buf offset = (.+?), target size = (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/security/EncryptionUtils.java","lineNumber":203,"sourceCode":"        int outputLength = inputBuffer.getInt();\n        outputBuffer = ByteBufferUtil.ensureCapacity(outputBuffer, outputLength, allowBufferResize);\n        compressor.uncompress(inputBuffer, outputBuffer);\n        outputBuffer.position(0).limit(outputLength);\n\n        return outputBuffer;\n    }\n\n    public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, ICompressor compressor) throws IOException\n    {\n        int outputLength = readInt(input, inputOffset);\n        inputOffset += 4;\n        inputLength -= 4;\n\n        if (output.length - outputOffset < outputLength)\n        {\n            String msg = String.format(\"buffer to uncompress into is not large enough; buf size = %d, buf offset = %d, target size = %s\",\n                                       output.length, outputOffset, outputLength);\n            throw new IllegalStateException(msg);\n        }\n\n        return compressor.uncompress(input, inputOffset, inputLength, output, outputOffset);\n    }\n\n    private static int readInt(byte[] input, int inputOffset)\n    {\n        return  (input[inputOffset + 3] & 0xFF)\n                | ((input[inputOffset + 2] & 0xFF) << 8)\n                | ((input[inputOffset + 1] & 0xFF) << 16)\n                | ((input[inputOffset] & 0xFF) << 24);\n    }\n\n    /**\n     * A simple {@link java.nio.channels.Channel} adapter for ByteBuffers.\n     */\n    private static final class ChannelAdapter implements WritableByteChannel\n    {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/security/EncryptionUtils.java#L185-L221","documentation":"Fired in EncryptionUtils.uncompress when the supplied output buffer is smaller than the compressed frame's declared outputLength and allowBufferResize is false. It is a guard against under-sized caller-provided buffers during encrypted-frame decompression (SSL streaming paths).","triggerScenarios":"Thrown at src/java/org/apache/cassandra/security/EncryptionUtils.java:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide/resize the output buffer to at least the declared uncompressed length, or allow buffer resize (allowBufferResize=true)","Verify the compressed frame's declared outputLength matches the compressor's expectation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}