Fixed #9113 (false positive: (error) Buffer is accessed out of bounds)
This commit is contained in:
parent
fb8b9b12cb
commit
fcc5fad3ed
@ -588,6 +588,8 @@ void CheckBufferOverrun::bufferOverflow()
|
|||||||
argtok = argtok->astOperand2();
|
argtok = argtok->astOperand2();
|
||||||
if (!argtok || !argtok->variable())
|
if (!argtok || !argtok->variable())
|
||||||
continue;
|
continue;
|
||||||
|
if (argtok->valueType() && argtok->valueType()->pointer == 0)
|
||||||
|
continue;
|
||||||
// TODO: strcpy(buf+10, "hello");
|
// TODO: strcpy(buf+10, "hello");
|
||||||
const ValueFlow::Value bufferSize = getBufferSize(argtok);
|
const ValueFlow::Value bufferSize = getBufferSize(argtok);
|
||||||
if (bufferSize.intvalue <= 1)
|
if (bufferSize.intvalue <= 1)
|
||||||
|
@ -3388,6 +3388,11 @@ private:
|
|||||||
"}", settings);
|
"}", settings);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds: c\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds: c\n", errout.str());
|
||||||
|
|
||||||
|
check("void f(unsigned int addr) {\n"
|
||||||
|
" memset((void *)addr, 0, 1000);\n"
|
||||||
|
"}", settings0);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("struct AB { char a[10]; };\n"
|
check("struct AB { char a[10]; };\n"
|
||||||
"void foo(AB *ab) {\n"
|
"void foo(AB *ab) {\n"
|
||||||
" mystrncpy(x, ab->a, 100);\n"
|
" mystrncpy(x, ab->a, 100);\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user