28class PutenvStackArrayChecker :
public Checker<check::PostCall> {
30 BugType BT{
this,
"'putenv' called with stack-allocated string",
32 const CallDescription Putenv{CDM::CLibrary, {
"putenv"}, 1};
35 void checkPostCall(
const CallEvent &
Call, CheckerContext &
C)
const;
39void PutenvStackArrayChecker::checkPostCall(
const CallEvent &
Call,
44 SVal ArgV =
Call.getArgSVal(0);
45 const Expr *ArgExpr =
Call.getArgExpr(0);
54 const auto *StackFrameFuncD =
55 dyn_cast_or_null<FunctionDecl>(SSR->getStackFrame()->getDecl());
56 if (StackFrameFuncD && StackFrameFuncD->isMain())
59 StringRef ErrorMsg =
"The 'putenv' function should not be called with "
60 "arrays that have automatic storage";
61 ExplodedNode *N =
C.generateErrorNode();
62 auto Report = std::make_unique<PathSensitiveBugReport>(BT, ErrorMsg, N);
67 C.emitReport(std::move(
Report));
70void ento::registerPutenvStackArray(CheckerManager &Mgr) {
74bool ento::shouldRegisterPutenvStackArray(
const CheckerManager &) {
bool matches(const CallEvent &Call) const
Returns true if the CallEvent is a call to a function that matches the CallDescription.
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Simple checker classes that implement one frontend (i.e.
const MemSpace * getMemorySpaceAs(ProgramStateRef State) const
const MemRegion * getAsRegion() const
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
const char *const SecurityError
The JSON file list parser is used to communicate input to InstallAPI.