Error C4789 from Visual Studio 2017 linker

Viewed 923

This is 64-bit Windows 7, Visual Studio 2017, C++ project.

When I do a release build with compiler option /sdl I am getting error 4789 (this is a warning if /sdl is not enabled).

1>Finished searching libraries
1>Generating code
1>c:\program files (x86)\windows kits\10\include\10.0.10586.0\ucrt\corecrt_memcpy_s.h(50): error C4789: buffer 'buffer' of size 262144 bytes will be overrun; 262143 bytes will be written starting at offset 2
1>All 2506 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.

I'd like to track down the cause of the error. Reading the MS docs on C4789 suggests there is one of the functions memset, wmemset, memcpy or strcpy which specifies an operation length > destination length. Further, this must be known at compile/link time, meaning that both the destination size and operation length are constants.

My difficulty is that there are literally hundreds of uses of the named functions in my project, and the linker does not identify which one is erroneous. I also searched for only those with a destination named 'buffer', with no luck.

Is there any way to narrow down the cause of the error?

0 Answers
Related