mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:05:08 +00:00
Driver: Buffer: Fix PVS-Studio warning.
V1004 The 'data' pointer was used unsafely after it was verified against nullptr. Check lines: 123, 132. fortbuf.c 132
This commit is contained in:
parent
5a8f2cb640
commit
57e9528f95
@ -120,17 +120,13 @@ FORT_API NTSTATUS fort_buffer_prepare(
|
|||||||
buf->out_top = new_top;
|
buf->out_top = new_top;
|
||||||
} else {
|
} else {
|
||||||
PFORT_BUFFER_DATA data = fort_buffer_data_alloc(buf, len);
|
PFORT_BUFFER_DATA data = fort_buffer_data_alloc(buf, len);
|
||||||
const UINT32 buf_top = data ? data->top : FORT_BUFFER_SIZE;
|
if (data == NULL) {
|
||||||
const UINT32 new_top = buf_top + len;
|
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "FORT: Buffer OOM: len=%d\n", len);
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
if (new_top > FORT_BUFFER_SIZE) {
|
|
||||||
DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL,
|
|
||||||
"FORT: Buffer Overflow: data=%p len=%d\n", data, len);
|
|
||||||
return STATUS_BUFFER_TOO_SMALL; /* drop on buffer overflow */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = data->p + buf_top;
|
*out = data->p + data->top;
|
||||||
data->top = new_top;
|
data->top += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user