Jaysonyan added inline comments.
Herald added a subscriber: carlosgalvezp.
Comment at:
clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:89
+Result.Context->getTargetInfo());
+diag(loc, "usage of %%n can lead to unsafe writing to memory");
+ }
-
aaron.ballman added inline comments.
Comment at:
clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:43-57
+ auto PrintfDecl = functionDecl(hasName("::printf"));
+ auto FprintfDecl = functionDecl(hasName("::fprintf"));
+ auto VfprintfDecl = functionDecl(has
Jaysonyan added inline comments.
Comment at:
clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:43-57
+ auto PrintfDecl = functionDecl(hasName("::printf"));
+ auto FprintfDecl = functionDecl(hasName("::fprintf"));
+ auto VfprintfDecl = functionDecl(hasName
aaron.ballman added inline comments.
Comment at:
clang-tools-extra/clang-tidy/bugprone/PercentNFormatSpecifierCheck.cpp:26-27
+ bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier &FS,
+ const char *startSpecifier,
+
Jaysonyan updated this revision to Diff 381103.
Jaysonyan retitled this revision from "Add %n format specifier warning" to "Add
%n format specifier warning to clang-tidy".
Jaysonyan added a comment.
Herald added a subscriber: mgorny.
Herald added a project: clang-tools-extra.
Move check for `%n`
Quuxplusone added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230
+def warn_printf_n_specifier : Warning<
+ "usage of '%%n' can lead to unsafe writing to memory">,
InGroup;
def warn_printf_data_arg_not_used : Warning<
Jaysony
Jaysonyan added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230
+def warn_printf_n_specifier : Warning<
+ "usage of '%%n' can lead to unsafe writing to memory">,
InGroup;
def warn_printf_data_arg_not_used : Warning<
aaron.bal
aaron.ballman added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230
+def warn_printf_n_specifier : Warning<
+ "usage of '%%n' can lead to unsafe writing to memory">,
InGroup;
def warn_printf_data_arg_not_used : Warning<
Quuxp
Quuxplusone added inline comments.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9230
+def warn_printf_n_specifier : Warning<
+ "usage of '%%n' can lead to unsafe writing to memory">,
InGroup;
def warn_printf_data_arg_not_used : Warning<
FWIW, I
aaron.ballman added a comment.
The trouble with this diagnostic is that it throws the baby out with the
bathwater. It is possible to securely use `%n`, so we can't have this warning
be on by default because it will have too high of a false positive rate.
However, we typically don't introduce ne
Jaysonyan added a comment.
Since no discussion came out of the RFC I'll leave the warning under the
`-Wformat-n-specifier` flag under `-Wformat`
unless there's other ideas brought up. Would appreciate any reviews at this
points! :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTI
11 matches
Mail list logo