Search code examples
cstringmemorybuffer-overflowmemory-corruption

string overflow detection in C


We are using DevPartners boundchecker for detecting memory leak issues. It is doing a wonderful job, though it does not find string overflows like the following

char szTest [1] = "";

for (i = 0; i < 100; i ++) {

    strcat (szTest, "hi");
}

Question-1: Is their any way, I can make BoundsChecker to detect this?

Question-2: Is their any other tool that can detect such issues?


Solution

  • I tried it in my devpartner (msvc6.6) (devpartner 7.2.0.372)

    I confirm your observed behavior. I get an access violation after about 63 passes of the loop.

    What does compuware have to say about the issue?

    CppCheck will detect this issue.