Improve static checks for sprintf and __builtin___sprintf_chk
authorserge-sans-paille <sguelton@redhat.com>
Thu, 12 Dec 2019 17:38:31 +0000 (18:38 +0100)
committerserge-sans-paille <sguelton@redhat.com>
Sat, 25 Jan 2020 17:10:34 +0000 (18:10 +0100)
commit6d485ff455ea2b37fef9e06e426dae6c1241b231
tree0f593b713c9fec710d668a9b4f4628717fd8d092
parentd08563486e06df3ddb4d7c1018d1e1e762690ee8
Improve static checks for sprintf and __builtin___sprintf_chk

Implement a pessimistic evaluator of the minimal required size for a buffer
based on the format string, and couple that with the fortified version to emit a
warning when the buffer size is lower than the lower bound computed from the
format string.

Differential Revision: https://reviews.llvm.org/D71566
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/warn-fortify-source.c