Menu

false positive in checking memset/memcpy

Grissiom
2021-08-04
2021-11-11
  • Grissiom

    Grissiom - 2021-08-04

    Small test code:

    void func(void)
    {
            some_type_t buf;
            memset(&buf, 0, sizeof(buf));
    }
    

    checker yield:

    $ cppcheck --bug-hunting t.c 
    Checking t.c ...
    t.c:5:8: error: Buffer read/write, when calling 'memset' it cannot be determined that 1st argument is not overflowed [bughuntingBufferOverflow]
     memset(&buf, 0, sizeof(buf));
    

    IMHO, the code is right, the checker is wrong. Am I wrong with this?

     
  • Daniel Marjamäki

    Yes I agree the code looks safe.

     
  • Daniel Marjamäki

     
  • Grissiom

    Grissiom - 2021-11-08

    Is there any progress? This problem bothered me very much.... Maybe you could point out where and how to fix it, I could fire a PR if I could fix it by myself.

     
  • Daniel Marjamäki

    sorry for late reply. no there was no progress yet. I need to dig in a little to even see where the problem is.. but spontanously it should be something in exprengine.cpp .. maybe in the function executeFunctionCall.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.