{"record":{"id":"ea345cfb96f4d0c2","repo":"jstedfast/MailKit","slug":"outputbuffer","errorCode":null,"errorMessage":"outputBuffer","messagePattern":"outputBuffer","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/Security/Ntlm/DES.cs","lineNumber":120,"sourceCode":"\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}\n\n\t\t\tpublic byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount)\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","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Security/Ntlm/DES.cs#L102-L138","documentation":"DES.TransformBlock throws ArgumentNullException with parameter name \"outputBuffer\" when the destination array is null. After validating the input, it checks that a real buffer exists to receive the encrypted/decrypted block before writing to outputOffset.","triggerScenarios":"Calling des.TransformBlock(input, 0, 8, null, 0) — outputBuffer null even when you intend only to measure size (not supported by this transform).","commonSituations":"APIs that allow a null output to query required size being misused against this block transform; an uninitialized output array variable; refactoring that changed in-place transformation to separate output buffers.","solutions":["Allocate an output array of at least 8 bytes at outputOffset before calling.","If you intended in-place transformation, pass the input buffer as the output buffer (DES allows same-buffer operation at the same offset).","Verify the output variable assignment isn't conditional code that skipped initialization."],"exampleFix":"// before\ndes.TransformBlock(input, 0, 8, output, 0); // output null\n\n// after\nvar output = new byte[8];\ndes.TransformBlock(input, 0, 8, output, 0);","handlingStrategy":"validation","validationCode":"var output = outputBuffer ?? new byte[8];\ndes.TransformBlock(input, 0, 8, output, 0);","typeGuard":"static bool CanHoldBlock(byte[] buf, int off) => buf != null && off + 8 <= buf.Length;","tryCatchPattern":"try {\n    des.TransformBlock(input, 0, 8, output, 0);\n} catch (ArgumentNullException ex) when (ex.ParamName == \"outputBuffer\") {\n    // allocate output and retry\n    output = new byte[8];\n}","preventionTips":["Allocate the output buffer (>= 8 bytes, block-aligned for loops) before starting the transform.","For in-place transforms pass the same buffer for input and output.","Don't reuse null-output size-query patterns from other crypto APIs."],"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"}