From: Ted Kremenek Date: Fri, 29 Jan 2010 01:43:31 +0000 (+0000) Subject: Alternate format string checking: check if the number of format specifiers exceeds... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da51f0d136df131a0137c0ec1069fb586d8a296a;p=clang Alternate format string checking: check if the number of format specifiers exceeds the number of arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94785 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index d856a2323a..81c309be51 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1418,6 +1418,18 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier return true; } + + // The remaining checks depend on the data arguments. + if (HasVAListArg) + return true; + + if (NumConversions > NumDataArgs) { + S.Diag(getLocationOfByte(CS.getStart()), + diag::warn_printf_insufficient_data_args) + << getFormatRange(); + // Don't do any more checking. + return false; + } return true; }