{"record":{"id":"08ab35827c957443","repo":"jstedfast/MailKit","slug":"buffer","errorCode":null,"errorMessage":"buffer","messagePattern":"buffer","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/Security/Ntlm/HMACMD5.cs","lineNumber":103,"sourceCode":"\t\t\thash.Reset ();\n\n\t\t\treturn value;\n\t\t}\n\n\t\tpublic void Initialize ()\n\t\t{\n\t\t\thash.Init (new KeyParameter (Key));\n\t\t}\n\n\t\tpublic void Clear ()\n\t\t{\n\t\t\tDispose (false);\n\t\t}\n\n\t\tpublic byte[] ComputeHash (byte[] buffer, int offset, int count)\n\t\t{\n\t\t\tif (buffer == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (buffer));\n\n\t\t\tif (offset < 0 || offset > buffer.Length)\n\t\t\t\tthrow new ArgumentOutOfRangeException (nameof (offset));\n\n\t\t\tif (count < 0 || offset > buffer.Length - count)\n\t\t\t\tthrow new ArgumentOutOfRangeException (nameof (count));\n\n\t\t\tif (disposed)\n\t\t\t\tthrow new ObjectDisposedException (\"HashAlgorithm\");\n\n\t\t\tHashCore (buffer, offset, count);\n\t\t\thashValue = HashFinal ();\n\n\t\t\treturn hashValue;\n\t\t}\n\n\t\tpublic byte[] ComputeHash (byte[] buffer)\n\t\t{","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Security/Ntlm/HMACMD5.cs#L85-L121","documentation":"Guard in HMACMD5.ComputeHash: the 'buffer' argument (the input data to hash) was null. The hash computation needs a real byte array, so null is rejected with ArgumentNullException before range checks on offset/count.","triggerScenarios":"Calling ComputeHash(null, 0, 0), often when the message body came from an upstream null value.","commonSituations":"NTLM signing of a message whose payload buffer was never populated.","solutions":["Allocate or fetch the buffer before hashing","Use ComputeHash(emptyArray) if hashing an empty payload intentionally","Catch ArgumentNullException at the signing boundary"],"exampleFix":"// before\nhmac.ComputeHash(payload, 0, payload.Length);\n// after\nif (payload != null)\n\thmac.ComputeHash(payload, 0, payload.Length);","handlingStrategy":"validation","validationCode":"if (buffer == null) throw new ArgumentException(\"buffer must not be null\");","typeGuard":"bool HasData(byte[] b) => b != null;","tryCatchPattern":"try { hmac.ComputeHash(buf, off, cnt); } catch (ArgumentNullException) { /* null payload */ }","preventionTips":["Use Array.Empty<byte>() for intentional empty payloads","Null-check upstream message bodies","Keep signing entry points defensive"],"tags":["csharp","hmac","argument-null"],"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"}