[PATCH] D111833: [clang] Fortify warning for scanf calls with field width too big.
George Burgess IV via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 19 18:25:08 PDT 2021
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.
LGTM % nits -- thanks for this! :)
================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:836
+def warn_fortify_scanf_overflow : Warning <
+ "'%0' may overflow; destination buffer in argument %1 has size "
----------------
nit: s/Warning </Warning</
================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:838
+ "'%0' may overflow; destination buffer in argument %1 has size "
+ "%2, but the corresponding field width plus null byte is %3">,
+ InGroup<FortifySource>;
----------------
nit: please s/null/NUL/ for consistency with elsewhere
================
Comment at: clang/lib/Sema/SemaChecking.cpp:415
+ // argument whose size we want.
+ using ComputeSizeFunction = std::function<Optional<llvm::APSInt>(unsigned)>;
+
----------------
optional: llvm generally prefers `FunctionRef`s for simplicity and speed. if it's easy to refactor to use those (seems like it may be), please do. otherwise, it's not a big deal.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111833/new/
https://reviews.llvm.org/D111833
More information about the cfe-commits
mailing list