{"record":{"id":"90d8d37001837364","repo":"aeron-io/aeron","slug":"insufficient-length","errorCode":null,"errorMessage":"Insufficient length: ","messagePattern":"Insufficient length: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/protocol/ResolutionEntryFlyweight.java","lineNumber":279,"sourceCode":"        }\n\n        return this;\n    }\n\n    /**\n     * Get the address for the entry by copying it into the destination buffer.\n     *\n     * @param dstBuffer into which the address will be copied.\n     * @return length of the address copied.\n     */\n    public int getAddress(final byte[] dstBuffer)\n    {\n        switch (resType())\n        {\n            case RES_TYPE_NAME_TO_IP4_MD:\n                if (ADDRESS_LENGTH_IP4 > dstBuffer.length)\n                {\n                    throw new IllegalArgumentException(\"Insufficient length: \" + dstBuffer.length);\n                }\n                getBytes(ADDRESS_FIELD_OFFSET, dstBuffer, 0, ADDRESS_LENGTH_IP4);\n                return ADDRESS_LENGTH_IP4;\n\n            case RES_TYPE_NAME_TO_IP6_MD:\n                if (ADDRESS_LENGTH_IP6 > dstBuffer.length)\n                {\n                    throw new IllegalArgumentException(\"Insufficient length: \" + dstBuffer.length);\n                }\n                getBytes(ADDRESS_FIELD_OFFSET, dstBuffer, 0, ADDRESS_LENGTH_IP6);\n                return ADDRESS_LENGTH_IP6;\n        }\n\n        throw new IllegalStateException(\"unknown RES_TYPE=\" + resType());\n    }\n\n    /**\n     * Append the address to the provided {@link Appendable} in ASCII format.","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/protocol/ResolutionEntryFlyweight.java#L261-L297","documentation":"getAddress for RES_TYPE_NAME_TO_IP4_MD throws IllegalArgumentException when the caller-supplied dstBuffer is shorter than the 4-byte IPv4 address it must hold. This is a defensive pre-copy length check to prevent ArrayIndexOutOfBoundsException inside the underlying getBytes copy.","triggerScenarios":"Calling getAddress(byte[] dstBuffer) on an entry with resType RES_TYPE_NAME_TO_IP4_MD while dstBuffer.length < ADDRESS_LENGTH_IP4 (4).","commonSituations":"Reusing a shared scratch byte[] sized for one address family (e.g. 16 bytes for IPv6 names) with entries of the other family, or passing a freshly allocated zero-length array.","solutions":["Allocate dstBuffer with at least ADDRESS_LENGTH_IP4 (4) bytes for IPv4 entries — using the IP6 length (16) for all cases is safe","Use the static addressLength(resType) helper to size the buffer per entry","Switch to the appendTo(Appendable) variant if you only need the address as text"],"exampleFix":"// before\nbyte[] dst = new byte[0];\nint len = entry.getAddress(dst);\n// after\nbyte[] dst = new byte[ResolutionEntryFlyweight.ADDRESS_LENGTH_IP6];\nint len = entry.getAddress(dst);","handlingStrategy":"validation","validationCode":"if (dstBuffer.length < ResolutionEntryFlyweight.ADDRESS_LENGTH_IP4) { throw new IllegalArgumentException(\"dst too small\"); }","typeGuard":"null","tryCatchPattern":"try { int len = entry.getAddress(dst); }\ncatch (IllegalArgumentException e) { /* resize buffer and retry */ }","preventionTips":["Use ADDRESS_LENGTH_IP6-sized (16 byte) buffers for all address reads","Call addressLength(resType()) to size buffers dynamically"],"tags":["aeron","protocol","buffer","argument-validation"],"backgroundTag":"argument-out-of-range","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}