[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 24 11:09:00 PST 2022


steakhal requested changes to this revision.
steakhal added a comment.
This revision now requires changes to proceed.

Oh wait, should we accept this given this serious limitation?



================
Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:475-479
+def CStringUninitializedRead : Checker<"UninitializedRead">,
+  HelpText<"Checks if the string manipulation function would read uninitialized bytes">,
+  Dependencies<[CStringModeling]>,
+  Documentation<HasAlphaDocumentation>;
+  
----------------
We also need documentation in the `clang/docs/analyzer/checkers.rst`.
Please also note the limitation we experienced and described here.
Also refer back to the Umbrella GitHub issue in that section.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:262
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedRead(CheckerContext &C, ProgramStateRef State,
+                             const Expr *E) const;
----------------



================
Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:378
+    if (StInBound->getSVal(ER).isUndef()) {
+      llvm::errs() << "Reading from " << ER << "\n";
+      emitUninitializedRead(C, StInBound, Buffer.Expression);
----------------
Remove this line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120489/new/

https://reviews.llvm.org/D120489



More information about the cfe-commits mailing list