{"record":{"id":"88539de559f6bbaa","repo":"jstedfast/MailKit","slug":"inputbuffer","errorCode":null,"errorMessage":"inputBuffer","messagePattern":"inputBuffer","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/Security/Ntlm/DES.cs","lineNumber":108,"sourceCode":"\t\t\t\tget { return false; }\n\t\t\t}\n\n\t\t\tpublic bool CanTransformMultipleBlocks {\n\t\t\t\tget { return false; }\n\t\t\t}\n\n\t\t\tpublic int InputBlockSize {\n\t\t\t\tget { return 8; }\n\t\t\t}\n\n\t\t\tpublic int OutputBlockSize {\n\t\t\t\tget { return 8; }\n\t\t\t}\n\n\t\t\tpublic int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)\n\t\t\t{\n\t\t\t\tif (inputBuffer == null)\n\t\t\t\t\tthrow new ArgumentNullException (\"inputBuffer\");\n\n\t\t\t\tif (inputOffset < 0 || inputOffset > inputBuffer.Length)\n\t\t\t\t\tthrow new ArgumentOutOfRangeException (\"inputOffset\");\n\n\t\t\t\tif (inputCount < 0 || inputOffset > inputBuffer.Length - inputCount)\n\t\t\t\t\tthrow new ArgumentOutOfRangeException (\"inputCount\");\n\n\t\t\t\tif (inputCount != 8)\n\t\t\t\t\tthrow new ArgumentOutOfRangeException (\"inputCount\", \"Can only transform 8 bytes at a time.\");\n\n\t\t\t\tif (outputBuffer == null)\n\t\t\t\t\tthrow new ArgumentNullException (\"outputBuffer\");\n\n\t\t\t\tif (outputOffset < 0 || outputOffset > outputBuffer.Length - 8)\n\t\t\t\t\tthrow new ArgumentOutOfRangeException (\"outputOffset\");\n\n\t\t\t\treturn engine.ProcessBlock (inputBuffer, inputOffset, outputBuffer, outputOffset);\n\t\t\t}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Security/Ntlm/DES.cs#L90-L126","documentation":"DES.TransformBlock (MailKit's internal NTLM DES implementation) throws ArgumentNullException with parameter name \"inputBuffer\" when the input byte array is null. The block cipher needs a real 8-byte input block to encrypt/decrypt, so the null check is the first validation performed.","triggerScenarios":"Calling des.TransformBlock(null, 0, 8, output, 0) — any invocation with a null inputBuffer, regardless of offset/count values.","commonSituations":"Using the internal MailKit.Security.Ntlm DES class directly for NTLM session keys; passing a key/password-derived buffer that failed to initialize; migrating code that relied on .NET's ICryptoTransform with a null input by mistake.","solutions":["Pass a valid non-null byte array containing the data block to transform.","Verify the upstream key derivation (e.g., DES password hashing for NTLM) actually produced a buffer.","Prefer computing via the higher-level APIs (NtlmTransform/ComputeDesMac style helpers) rather than the raw transform when available."],"exampleFix":"// before\ndes.TransformBlock(input, 0, 8, output, 0); // input may be null\n\n// after\nif (input != null)\n    des.TransformBlock(input, 0, 8, output, 0);","handlingStrategy":"validation","validationCode":"if (input == null || input.Length < 8) throw new InvalidOperationException(\"need a full 8-byte DES block\");\ndes.TransformBlock(input, 0, 8, output, 0);","typeGuard":"static bool IsValidBlock(byte[] b, int off) => b != null && off >= 0 && off + 8 <= b.Length;","tryCatchPattern":"try {\n    des.TransformBlock(inputBuffer, inputOffset, 8, outputBuffer, 0);\n} catch (ArgumentNullException ex) when (ex.ParamName == \"inputBuffer\") {\n    // null input: initialize or abort\n}","preventionTips":["Verify key-derivation outputs are non-null before transforming.","Prefer invariants: input buffer always assigned at construction of the transform loop.","Use Debug.Assert for preconditions in NTLM helper code during development."],"tags":["mailkit","ntlm","des","null-argument"],"backgroundTag":"null-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}