MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / terminateStrncpyError

Method terminateStrncpyError

lib/checkbufferoverrun.cpp:811–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809}
810
811void CheckBufferOverrunImpl::terminateStrncpyError(const Token *tok, const std::string &varname)
812{
813 const std::string shortMessage = "The buffer '$symbol' may not be null-terminated after the call to strncpy().";
814 reportError(tok, Severity::warning, "terminateStrncpy",
815 "$symbol:" + varname + '\n' +
816 shortMessage + '\n' +
817 shortMessage + ' ' +
818 "If the source string's size fits or exceeds the given size, strncpy() does not add a "
819 "zero at the end of the buffer. This causes bugs later in the code if the code "
820 "assumes buffer is null-terminated.", CWE170, Certainty::inconclusive);
821}
822//---------------------------------------------------------------------------
823
824void CheckBufferOverrunImpl::argumentSize()

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected