I’m getting a warning from Prefast (WDK 7600.16385.1) that I don’t
understand. Probably I’m missing something obvious, but I’m just not
seeing it. Here’s the code (the request is from a DeviceIoControl call,
and the IOCTL is defined as METHOD_DIRECT_FROM_HARDWARE):
NTSTATUS vmeintWait(PDEVICE_CONTEXT dc, WDFREQUEST Request)
{
NTSTATUS status = STATUS_SUCCESS;
VMEINT_WAIT *in = NULL;
VMEINT_WAIT_RESULT *out = NULL;
size_t size = 0;
do {
// Get the input parameters
if (!NT_SUCCESS(status = WdfRequestRetrieveInputBuffer (
Request, sizeof(*in),
(PVOID *)&in, NULL)))
{
break;
}
// Get the output buffer to write to
if (!NT_SUCCESS(status = WdfRequestRetrieveOutputBuffer(
Request, sizeof(*out),
(PVOID *)&out, &size)))
{
break;
}
RtlZeroMemory(out, sizeof(VMEINT_WAIT_RESULT));
…
I get the following warning on the RtlZeroMemory:
warning 6386: (PFD)Buffer overrun while writing to ‘out’: the
writable size is ‘size’ bytes, but ‘12’ bytes may be written.
I just don’t see what the complaint is; does anyone else see what I’ve
done wrong? Or at least, what I need to do to convince Prefast that
it’s OK?
TIA,
– mkj
//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________