[clang] 56eaf86 - [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 3 10:51:11 PST 2022


Author: Shivam
Date: 2022-03-04T00:21:06+05:30
New Revision: 56eaf869be27585bff7320505dfad32b5b3b6189

URL: https://github.com/llvm/llvm-project/commit/56eaf869be27585bff7320505dfad32b5b3b6189
DIFF: https://github.com/llvm/llvm-project/commit/56eaf869be27585bff7320505dfad32b5b3b6189.diff

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

Few weeks back I was experimenting with reading the uninitialized values from src , which is actually a bug but the CSA seems to give up at that point . I was curious about that and I pinged @steakhal on the discord and according to him this seems to be a genuine issue and needs to be fix. So I goes with fixing this bug and thanks to @steakhal who help me creating this patch. This feature seems to break some tests but this was the genuine problem and the broken tests also needs to fix in certain manner. I add a test but yeah we need more tests,I'll try to add more tests.Thanks

Reviewed By: steakhal, NoQ

Differential Revision: https://reviews.llvm.org/D120489

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 54c9e887b8c8c..23c10431a5dfb 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -259,6 +259,8 @@ class CStringChecker : public Checker< eval::Call,
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
                          const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
+                             const Expr *E) const;
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
                                             ProgramStateRef state,
                                             NonLoc left,


        


More information about the cfe-commits mailing list