
VT103084 (Community Member) asked a question.
Veracode reported:
This call to ReadFile() contains a potential buffer overflow. The specified size of 92 bytes is larger than the space allocated to the destination buffer (88 bytes).
The code:
typedef struct
{
char myArray[82];
int number1;
int number2;
} MY_STRUCT;
void test_ExpectBufferOverflow(HANDLE handle)
{
DWORD nRead;
MY_STRUCT my_struct;
ReadFile(handle, &my_struct, sizeof(MY_STRUCT), &nRead, NULL);
}
This is 32-bit Windows code, compiler: MSVC14_X86.
I do not see how buffer overflow can happen here.
How should I fix this?
.png)
Hi @VT103084 (Community Member) - Our team can help you via a Consultation Call, which you can schedule via this link: https://community.veracode.com/s/article/How-to-schedule-a-consultation-call