CryptRand.FillBuffer shouldn't throw if the buffer is a zero-length array.

This commit is contained in:
Levi Broderick 2014-03-14 14:34:20 -07:00
parent ba58f29e31
commit 730b16df37
1 changed files with 5 additions and 2 deletions

View File

@ -16,9 +16,12 @@ namespace Microsoft.AspNet.Security.DataProtection
// the ArraySegment<> ctor performs bounds checking
var unused = new ArraySegment<byte>(buffer.Array, buffer.Offset, buffer.Count);
fixed (byte* pBuffer = &buffer.Array[buffer.Offset])
if (buffer.Count != 0)
{
BCryptUtil.GenRandom(pBuffer, buffer.Count);
fixed (byte* pBuffer = &buffer.Array[buffer.Offset])
{
BCryptUtil.GenRandom(pBuffer, buffer.Count);
}
}
}
}