[clang] [clang][StaticAnalyzer] Adding getentropy to CStringChecker. (PR #83675)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 05:53:47 PST 2024
================
@@ -2516,6 +2518,47 @@ void CStringChecker::evalSprintfCommon(CheckerContext &C, const CallEvent &Call,
C.addTransition(State);
}
+void CStringChecker::evalGetentropy(CheckerContext &C,
+ const CallEvent &Call) const {
+ DestinationArgExpr Buffer = {{Call.getArgExpr(0), 0}};
+ SizeArgExpr Size = {{Call.getArgExpr(1), 1}};
+ ProgramStateRef State = C.getState();
+ constexpr int BufferMaxSize = 256;
+
+ SVal SizeVal = C.getSVal(Size.Expression);
+ QualType SizeTy = Size.Expression->getType();
+
+ ProgramStateRef StateZeroSize, StateNonZeroSize;
+ std::tie(StateZeroSize, StateNonZeroSize) =
+ assumeZero(C, State, SizeVal, SizeTy);
+
+ SVal Buff = C.getSVal(Buffer.Expression);
+ State = checkNonNull(C, StateNonZeroSize, Buffer, Buff);
----------------
steakhal wrote:
`StateNonZeroSize` might be null here; see my previous comment.
https://github.com/llvm/llvm-project/pull/83675
More information about the cfe-commits
mailing list