VT103084 (Community Member) asked a question.

Is this a false positive?

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?

 


Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.