[PATCH] D71566: New checks for fortified sprintf

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 21:48:20 PST 2020


erik.pilkington added reviewers: aaron.ballman, rsmith.
erik.pilkington added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:422
+      size_t StrLen =
+          std::min(std::max(TypeSize, size_t(1)) - 1, FormatStrRef.size());
+      if (!analyze_format_string::ParsePrintfString(
----------------
Wait, does this actually return a smaller length if there is a null-terminator embedded in the string? It looks like Format->getString() returns a StringRef with embedded nul bytes and .size() is returning the length. You might have to do something like: `FormatStrRef.find('0');`. Can you add a test for this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71566/new/

https://reviews.llvm.org/D71566





More information about the cfe-commits mailing list